8000 1_22_update (#3) · bonfireprocessor/micropython@ea5e0f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea5e0f5

Browse files
ThomasHornschuhdpgeorgenickovsrobert-hhiabdalkader
committed
1_22_update (#3)
* rp2/rp2_flash: Lockout second core only when doing flash erase/write. Using the multicore lockout feature in the general atomic section makes it much more difficult to get correct. Signed-off-by: Damien George <damien@micropython.org> * rp2/mutex_extra: Implement additional mutex functions. These allow entering/exiting a mutex and also disabling/restoring interrupts, in an atomic way. Signed-off-by: Damien George <damien@micropython.org> * rp2/mpthreadport: Fix race with IRQ when entering atomic section. Prior to this commit there is a potential deadlock in mp_thread_begin_atomic_section(), when obtaining the atomic_mutex, in the following situation: - main thread calls mp_thread_begin_atomic_section() (for whatever reason, doesn't matter) - the second core is running so the main thread grabs the mutex via the call mp_thread_mutex_lock(&atomic_mutex, 1), and this succeeds - before the main thread has a chance to run save_and_disable_interrupts() a USB IRQ comes in and the main thread jumps off to process this IRQ - that USB processing triggers a call to the dcd_event_handler() wrapper from commit bcbdee2 - that then calls mp_sched_schedule_node() - that then attempts to obtain the atomic section, calling mp_thread_begin_atomic_section() - that call then blocks trying to obtain atomic_mutex - core0 is now deadlocked on itself, because the main thread has the mutex but the IRQ handler (which preempted the main thread) is blocked waiting for the mutex, which will never be free The solution in this commit is to use mutex enter/exit functions that also atomically disable/restore interrupts. Fixes issues micropython#12980 and micropython#13288. Signed-off-by: Damien George <damien@micropython.org> * all: Bump version to 1.22.1. Signed-off-by: Damien George <damien@micropython.org> * Generic STM32F401CD Port Compiles (not working yet...) * rp2/rp2_dma: Fix fetching 'write' buffers for writing not reading. Signed-off-by: Nicko van Someren <nicko@nicko.org> * rp2/machine_uart: Fix event wait in uart.flush() and uart.read(). Do not wait in the worst case up to the timeout. Fixes issue micropython#13377. Signed-off-by: robert-hh <robert@hammelrath.com> * renesas-ra/ra: Fix SysTick clock source. The SysTick_Config function must use the system/CPU clock to configure the ticks. Signed-off-by: iabdalkader <i.abdalkader@gmail.com> * renesas-ra/boards/ARDUINO_PORTENTA_C33: Fix the RTC clock source. Switch the RTC clock source to Sub-clock (XCIN). This board has 8000 an accurate LSE crystal, and it should be used for the RTC clock source. Signed-off-by: iabdalkader <i.abdalkader@gmail.com> * extmod/asyncio: Support gather of tasks that finish early. Adds support to asyncio.gather() for the case that one or more (or all) sub-tasks finish and/or raise an exception before the gather starts. Signed-off-by: Damien George <damien@micropython.org> * mimxrt/modmachine: Fix deepsleep wakeup pin ifdef. Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com> * extmod/modssl_mbedtls: Fix cipher iteration in SSLContext.get_ciphers. Prior to this commit it would skip every second cipher returned from mbedtls. The corresponding test is also updated and now passes on esp32, rp2, stm32 and unix. Signed-off-by: Damien George <damien@micropython.org> * rp2: Change machine.I2S and rp2.DMA to use shared DMA IRQ handlers. These separate drivers must share the DMA resource with each other. Fixes issue micropython#13380. Signed-off-by: Damien George <damien@micropython.org> * py/compile: Fix potential Py-stack overflow in try-finally with return. If a return is executed within the try block of a try-finally then the return value is stored on the top of the Python stack during the execution of the finally block. In this case the Python stack is one larger than it normally would be in the finally block. Prior to this commit, the compiler was not taking this case into account and could have a Python stack overflow if the Python stack used by the finally block was more than that used elsewhere in the function. In such a scenario the last argument of the function would be clobbered by the top-most temporary value used in the deepest Python expression/statement. This commit fixes that case by making sure enough Python stack is allocated to the function. Fixes issue micropython#13562. Signed-off-by: Damien George <damien@micropython.org> * renesas-ra/ra/ra_i2c: Fix 1 byte and 2 bytes read issue. Tested on Portenta C33 with AT24256B (addrsize=16) and SSD1306. Fixes issue micropython#13280. Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com> * extmod/btstack: Reset pending_value_handle before calling write-done cb. The pending_value_handle needs to be freed and reset before calling mp_bluetooth_gattc_on_read_write_status(), which will call the Python IRQ handler, which may in turn call back into BTstack to perform an action like a write. In that case the pending_value_handle will need to be available for the write/read/etc to proceed. Fixes issue micropython#13611. Signed-off-by: Damien George <damien@micropython.org> * extmod/btstack: Reset pending_value_handle before calling read-done cb. Similar to the previous commit but for MP_BLUETOOTH_IRQ_GATTC_READ_DONE: the pending_value_handle needs to be reset before calling mp_bluetooth_gattc_on_read_write_status(), which will call the Python IRQ handler, which may in turn call back into BTstack to perform an action like a write. In that case the pending_value_handle will need to be available for the write/read/etc to proceed. Fixes issue micropython#13634. Signed-off-by: Damien George <damien@micropython.org> * esp32/mpnimbleport: Release the GIL while doing NimBLE port deinit. In case callbacks must run (eg a disconnect event happens during the deinit) and the GIL must be obtained to run the callback. Fixes part of issue micropython#12349. Signed-off-by: Damien George <damien@micropython.org> * esp32: Increase NimBLE task stack size and overflow detection headroom. The Python BLE IRQ handler will most likely run on the NimBLE task, so its C stack must be large enough to accommodate reasonably complicated Python code (eg a few call depths). So increase this stack size. Also increase the headroom from 1024 to 2048 bytes. This is needed because (1) the esp32 architecture uses a fair amount of stack in general; and (2) by the time execution gets to setting the Python stack top via `mp_stack_set_top()` in this interlock code, about 600 bytes of stack are already used, which reduces the amount available for Python. Fixes issue micropython#12349. Signed-off-by: Damien George <damien@micropython.org> * all: Bump version to 1.22.2. Signed-off-by: Damien George <damien@micropython.org> * Submodule update --------- Signed-off-by: Damien George <damien@micropython.org> Signed-off-by: Nicko van Someren <nicko@nicko.org> Signed-off-by: robert-hh <robert@hammelrath.com> Signed-off-by: iabdalkader <i.abdalkader@gmail.com> Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com> Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com> Co-authored-by: Damien George <damien@micropython.org> Co-authored-by: Nicko van Someren <nicko@nicko.org> Co-authored-by: robert-hh <robert@hammelrath.com> Co-authored-by: iabdalkader <i.abdalkader@gmail.com> Co-authored-by: Kwabena W. Agyeman <kwagyeman@live.com> Co-authored-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
1 parent 92ae2a6 commit ea5e0f5

File tree

5 files changed

+208
-0
lines changed

5 files changed

+208
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"deploy": [
3+
"../deploy.md"
4+
],
5+
"docs": "",
6+
"features": [],
7+
"images": [
8+
"nucleo_f401re.jpg"
9+
],
10+
"mcu": "stm32f4",
11+
"product": "Nucleo F401CD",
12+
"thumbnail": "",
13+
"url": "",
14+
"vendor": "ST Microelectronics"
15+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#define MICROPY_HW_BOARD_NAME "STM32F401CD"
2+
#define MICROPY_HW_MCU_NAME "STM32F401xD"
3+
4+
5+
#define MICROPY_CONFIG_ROM_LEVEL MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES
6+
#define MICROPY_ENABLE_FINALISER (1)
7+
#define MICROPY_HELPER_REPL (1)
8+
#define MICROPY_PY_SYS_PS1_PS2 (1)
9+
#define MICROPY_PY_MACHINE_TIMER (1)
10+
#define MICROPY_ENABLE_SCHEDULER (1)
11+
#define MICROPY_KBD_EXCEPTION (1)
12+
#define MICROPY_PY_NETWORK (0)
13+
14+
#define MICROPY_PY_IO (1)
15+
#define MICROPY_PY_IO_IOBASE (1)
16+
#define MICROPY_PY_SYS_STDFILES (1)
17+
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
18+
19+
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
20+
#define MICROPY_PY_MICROPYTHON_STACK_USE (1)
21+
//#define MICROPY_PY_MACHINE (1)
22+
#define MICROPY_PY_OS_SYNC (1)
23+
#define MICROPY_PY_OS (1)
24+
25+
26+
#define MICROPY_HW_HAS_SWITCH (1)
27+
#define MICROPY_HW_HAS_FLASH (1)
28+
#define MICROPY_HW_ENABLE_RTC (1)
29+
#define MICROPY_HW_ENABLE_SERVO (1)
30+
#define MICROPY_HW_ENABLE_USB (1)
31+
#define MICROPY_HW_USB_FS (1)
32+
33+
// HSE is 25MHz
34+
// Default source for the clock is HSE.
35+
// For revisions of the board greater than C-01, HSE can be used as a
36+
// clock source by removing the #define MICROPY_HW_CLK_USE_HSE line
37+
#define MICROPY_HW_CLK_USE_HSI (0)
38+
39+
#if MICROPY_HW_CLK_USE_HSI
40+
#define MICROPY_HW_CLK_PLLM (16)
41+
#else
42+
#define MICROPY_HW_CLK_PLLM (15)
43+
#endif
44+
#define MICROPY_HW_CLK_PLLN (144)
45+
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV4)
46+
#define MICROPY_HW_CLK_PLLQ (5)
47+
48+
// UART config
49+
#define MICROPY_HW_UART2_TX (pin_A2)
50+
#define MICROPY_HW_UART2_RX (pin_A3)
51+
//#define MICROPY_HW_UART6_TX (pin_C6)
52+
//#define MICROPY_HW_UART6_RX (pin_C7)
53+
// UART 2 connects to the STM32F103 (STLINK) on the Nucleo board
54+
// and this is exposed as a USB Serial port.
55+
#define MICROPY_HW_UART_REPL PYB_UART_2
56+
#define MICROPY_HW_UART_REPL_BAUD 115200
57+
58+
// I2C buses
59+
#define MICROPY_HW_I2C1_SCL (pin_B8) // Arduino D15, pin 3 on CN10
60+
#define MICROPY_HW_I2C1_SDA (pin_B9) // D14, pin 5 on CN10
61+
#define MICROPY_HW_I2C2_SCL (pin_B10) // Arduino D6, pin 25 on CN10
62+
#define MICROPY_HW_I2C2_SDA (pin_B3) // Arduino D3, pin 31 on CN10
63+
#define MICROPY_HW_I2C3_SCL (pin_A8) // Arduino D7, pin 23 on CN10
64+
#define MICROPY_HW_I2C3_SDA (pin_C9) // pin 1 on CN10
65+
66+
// SPI buses
67+
#define MICROPY_HW_SPI1_NSS (pin_A15) // pin 17 on CN7
68+
#define MICROPY_HW_SPI1_SCK (pin_A5) // Arduino D13, pin 11 on CN10
69+
#define MICROPY_HW_SPI1_MISO (pin_A6) // Arduino D12, pin 13 on CN10
70+
#define MICROPY_HW_SPI1_MOSI (pin_A7) // Arduino D11, pin 15 on CN10
71+
72+
#define MICROPY_HW_SPI2_NSS (pin_B12) // pin 16 on CN10
73+
#define MICROPY_HW_SPI2_SCK (pin_B13) // pin 30 on CN10
74+
#define MICROPY_HW_SPI2_MISO (pin_B14) // pin 28 on CN10
75+
#define MICROPY_HW_SPI2_MOSI (pin_B15) // pin 26 on CN10
76+
77+
#define MICROPY_HW_SPI3_NSS (pin_A4) // Arduino A2, pin 32 on CN7
78+
#define MICROPY_HW_SPI3_SCK (pin_B3) // Arduino D3, pin 31 on CN10
79+
#define MICROPY_HW_SPI3_MISO (pin_B4) // Arduino D5, pin 27 on CN10
80+
#define MICROPY_HW_SPI3_MOSI (pin_B5) // Arduino D4, pin 29 on CN10
81+
82+
// USRSW is pulled low. Pressing the button makes the input go high.
83+
#define MICROPY_HW_USRSW_PIN (pin_A0)
84+
#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
85+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
86+
#define MICROPY_HW_USRSW_PRESSED (0)
87+
88+
// LEDs
89+
#define MICROPY_HW_LED1 (pin_C13) // Green LD2 LED on Nucleo
90+
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
91+
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MCU_SERIES = f4
2+
CMSIS_MCU = STM32F401xE
3+
AF_FILE = boards/stm32f401_af.csv
4+
LD_FILES = boards/stm32f401xd.ld boards/common_ifs.ld
5+
TEXT0_ADDR = 0x08000000
6+
TEXT1_ADDR = 0x08020000
7+
8+
#SRC_C += modos.c
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
D0,PA3
2+
D1,PA2
3+
D2,PA10
4+
D3,PB3
5+
D4,PB5
6+
D5,PB4
7+
D6,PB10
8+
D7,PA8
9+
D8,PA9
10+
D9,PC7
11+
D10,PB6
12+
D11,PA7
13+
D12,PA6
14+
D13,PA5
15+
D14,PB9
16+
D15,PB8
17+
A0,PA0
18+
A1,PA1
19+
A2,PA4
20+
A3,PB0
21+
A4,PC1
22+
A5,PC0
23+
PA0,PA0
24+
PA1,PA1
25+
PA2,PA2
26+
PA3,PA3
27+
PA4,PA4
28+
PA5,PA5
29+
PA6,PA6
30+
PA7,PA7
31+
PA8,PA8
32+
PA9,PA9
33+
PA10,PA10
34+
PA11,PA11
35+
PA12,PA12
36+
PA15,PA15
37+
PB0,PB0
38+
PB1,PB1
39+
PB2,PB2
40+
PB3,PB3
41+
PB4,PB4
42+
PB5,PB5
43+
PB6,PB6
44+
PB7,PB7
45+
PB8,PB8
46+
PB9,PB9
47+
PB10,PB10
48 10000 +
PB12,PB12
49+
PB13,PB13
50+
PB14,PB14
51+
PB15,PB15
52+
PC0,PC0
53+
PC1,PC1
54+
PC2,PC2
55+
PC3,PC3
56+
PC4,PC4
57+
PC5,PC5
58+
PC6,PC6
59+
PC7,PC7
60+
PC8,PC8
61+
PC9,PC9
62+
PC10,PC10
63+
PC11,PC11
64+
PC12,PC12
65+
PC13,PC13
66+
PC14,PC14
67+
PC15,PC15
68+
PD2,PD2
69+
PH0,PH0
70+
PH1,PH1
71+
LED_GREEN,PA5
72+
LED_ORANGE,PA5
73+
LED_RED,PA5
74+
LED_BLUE,PA4
75+
SW,PC13
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* This file is part of the MicroPython project, http://micropython.org/
2+
* The MIT License (MIT)
3+
* Copyright (c) 2019 Damien P. George
4+
*/
5+
#ifndef MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H
6+
#define MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H
7+
8+
// Oscillator values in Hz
9+
#define HSE_VALUE (8000000)
10+
#define LSE_VALUE (32768)
11+
#define EXTERNAL_CLOCK_VALUE (25000000)
12+
13+
// Oscillator timeouts in ms
14+
#define HSE_STARTUP_TIMEOUT (100)
15+
#define LSE_STARTUP_TIMEOUT (5000)
16+
17+
#include "boards/stm32f4xx_hal_conf_base.h"
18+
19+
#endif // MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H

0 commit comments

Comments
 (0)
0