8000 When compiling and porting stm32H750 to micro python, an error is reported · Issue #11629 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

When compiling and porting stm32H750 to micro python, an error is reported #11629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
klora-sun opened this issue May 26, 2023 · 8 comments
Closed

Comments

@klora-sun
Copy link

make BOARD=REG_H750
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
CC system_stm32.c
In file included from ../../py/obj.h:32,
from ./pin.h:33,
from ./mphalport.h:3,
from ../../py/mphal.h:35,
from system_stm32.c:78:
../../py/obj.h: In function 'mp_obj_is_float':
../../py/misc.h:54:50: error: size of unnamed array is negative
54 | #define MP_STATIC_ASSERT(cond) ((void)sizeof(char[1 - 2 * !(cond)]))
| ^
../../py/obj.h:197:5: note: in expansion of macro 'MP_STATIC_ASSERT'
197 | MP_STATIC_ASSERT(sizeof(mp_float_t) <= sizeof(mp_obj_t));
| ^~~~~~~~~~~~~~~~
-e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting
make: *** [../../py/mkrules.mk:83:build-REG_H750/system_stm32.o] 错误 1

When compiling and porting stm32H750 to micro python, an error is reported,Please tell me what is wrong and how it should be changed

@klora-sun klora-sun added the bug label May 26, 2023
@dpgeorge
Copy link
Member

It looks like you have a custom board definition, and you have not configured it correctly. Please share your board configuration files to make progress here with debugging.

@klora-sun
Copy link
Author

It looks like you have a custom board definition, and you have not configured it correctly. Please share your board configuration files to make progress here with debugging.

#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)
#define UINT_FMT "%u"
#define INT_FMT "%d"
typedef int mp_int_t; // must be pointer size
typedef unsigned int mp_uint_t; // must be pointer size

#define MICROPY_FATFS_EXFAT (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_ADC (1)
#define MICROPY_HW_ENABLE_DAC (1)
#define MICROPY_HW_ENABLE_USB (1)
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_ENABLE_SERVO (1)
#define MICROPY_HW_ENABLE_TIMER (1)
#define MICROPY_HW_ENABLE_SDCARD (1)
#define MICROPY_HW_ENABLE_MMCARD (0)

// Flash storage config
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)

#define MICROPY_BOARD_STARTUP REG_H7_board_startup
void REG_H7_board_startup(void);

#define MICROPY_BOARD_EARLY_INIT REG_H7_board_early_init
void REG_H7_board_early_init(void);

#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) REG_H7_board_enter_bootloader()
void REG_H7_board_enter_bootloader(void);

void REG_H7_board_low_power(int mode);
#define MICROPY_BOARD_LEAVE_STOP REG_H7_board_low_power(0);
#define MICROPY_BOARD_ENTER_STOP REG_H7_board_low_power(1);
#define MICROPY_BOARD_ENTER_STANDBY REG_H7_board_low_power(2);

void REG_H7_board_osc_enable(int enable);
#define MICROPY_BOARD_OSC_ENABLE REG_H7_board_osc_enable(1);
#define MICROPY_BOARD_OSC_DISABLE REG_H7_board_osc_enable(0);

// PLL1 400MHz/50MHz for SDMMC and FDCAN
// USB and RNG are clocked from the HSI48
#define MICROPY_HW_CLK_PLLM (5)
#define MICROPY_HW_CLK_PLLN (160)
#define MICROPY_HW_CLK_PLLP (2)
#define MICROPY_HW_CLK_PLLQ (16)
#define MICROPY_HW_CLK_PLLR (2)
#define MICROPY_HW_CLK_PLLVCI (RCC_PLL1VCIRANGE_2)
#define MICROPY_HW_CLK_PLLVCO (RCC_PLL1VCOWIDE)
#define MICROPY_HW_CLK_PLLFRAC (0)

// PLL2 200MHz for FMC and QSPI.
#define MICROPY_HW_CLK_PLL2M (5)
#define MICROPY_HW_CLK_PLL2N (80)
#define MICROPY_HW_CLK_PLL2P (2)
#define MICROPY_HW_CLK_PLL2Q (2)
#define MICROPY_HW_CLK_PLL2R (2)
#define MICROPY_HW_CLK_PLL2VCI (RCC_PLL2VCIRANGE_2)
#define MICROPY_HW_CLK_PLL2VCO (RCC_PLL2VCOWIDE)
#define MICROPY_HW_CLK_PLL2FRAC (0)

// PLL3 160MHz for ADC and SPI123
#define MICROPY_HW_CLK_PLL3M (5)
#define MICROPY_HW_CLK_PLL3N (160)
#define MICROPY_HW_CLK_PLL3P (2)
#define MICROPY_HW_CLK_PLL3Q (5)
#define MICROPY_HW_CLK_PLL3R (2)
#define MICROPY_HW_CLK_PLL3VCI (RCC_PLL3VCIRANGE_2)
#define MICROPY_HW_CLK_PLL3VCO (RCC_PLL3VCOWIDE)
#define MICROPY_HW_CLK_PLL3FRAC (0)

// HSE in BYPASS mode.
#define MICROPY_HW_CLK_USE_BYPASS (0)

// Bus clock divider values
#define MICROPY_HW_CLK_AHB_DIV (RCC_HCLK_DIV2)
#define MICROPY_HW_CLK_APB1_DIV (RCC_APB1_DIV2)
#define MICROPY_HW_CLK_APB2_DIV (RCC_APB2_DIV2)
#define MICROPY_HW_CLK_APB3_DIV (RCC_APB3_DIV2)
#define MICROPY_HW_CLK_APB4_DIV (RCC_APB4_DIV2)

// Peripheral clock sources
#define MICROPY_HW_RCC_HSI48_STATE (RCC_HSI48_ON)
#define MICROPY_HW_RCC_USB_CLKSOURCE (RCC_USBCLKSOURCE_HSI48)
#define MICROPY_HW_RCC_RTC_CLKSOURCE (RCC_RTCCLKSOURCE_LSI)
#define MICROPY_HW_RCC_FMC_CLKSOURCE (RCC_FMCCLKSOURCE_PLL2)
#define MICROPY_HW_RCC_RNG_CLKSOURCE (RCC_RNGCLKSOURCE_HSI48)
#define MICROPY_HW_RCC_ADC_CLKSOURCE (RCC_ADCCLKSOURCE_PLL3)
#define MICROPY_HW_RCC_SDMMC_CLKSOURCE (RCC_SDMMCCLKSOURCE_PLL)
#define MICROPY_HW_RCC_FDCAN_CLKSOURCE (RCC_FDCANCLKSOURCE_PLL)
#define MICROPY_HW_RCC_SPI123_CLKSOURCE (RCC_SPI123CLKSOURCE_PLL3)
#define MICROPY_HW_RCC_I2C123_CLKSOURCE (RCC_I2C123CLKSOURCE_D2PCLK1)
#define MICROPY_HW_RCC_QSPI_CLKSOURCE (RCC_QSPICLKSOURCE_PLL2)

// There is an external 32kHz oscillator
#define RTC_ASYNCH_PREDIV (0)
#define RTC_SYNCH_PREDIV (0x7fff)
#define MICROPY_HW_RTC_USE_BYPASS (0)
#define MICROPY_HW_RTC_USE_US (1)
#define MICROPY_HW_RTC_USE_CALOUT (0)

#if (MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE == 0)
// QSPI flash #1 for storage
#define MICROPY_HW_QSPI_PRESCALER (2) // 100MHz
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (27)
#define MICROPY_HW_SPIFLASH_SIZE_BITS (128 * 1024 * 1024)
#define MICROPY_HW_QSPIFLASH_CS (pyb_pin_QSPI2_CS)
#define MICROPY_HW_QSPIFLASH_SCK (pyb_pin_QSPI2_CLK)
#define MICROPY_HW_QSPIFLASH_IO0 (pyb_pin_QSPI2_D0)
#define MICROPY_HW_QSPIFLASH_IO1 (pyb_pin_QSPI2_D1)
#define MICROPY_HW_QSPIFLASH_IO2 (pyb_pin_QSPI2_D2)
#define MICROPY_HW_QSPIFLASH_IO3 (pyb_pin_QSPI2_D3)

// SPI flash #1, block device config
extern const struct _mp_spiflash_config_t spiflash_config;
extern struct _spi_bdev_t spi_bdev;
#define MICROPY_HW_BDEV_IOCTL(op, arg) (
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) :
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) :
spi_bdev_ioctl(&spi_bdev, (op), (arg))
)
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n))
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n))
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev)
#endif

// 4 wait states
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_2

// UART config
#define MICROPY_HW_UART1_TX (pin_A9)
#define MICROPY_HW_UART1_RX (pin_A10)
#define MICROPY_HW_UART_REPL PYB_UART_1
#define MICROPY_HW_UART_REPL_BAUD 115200

// UART config
#define MICROPY_HW_UART8_TX (pin_J8)
#define MICROPY_HW_UART8_RX (pin_J9)

// I2C busses
#define MICROPY_HW_I2C3_SCL (pin_H7)
#define MICROPY_HW_I2C3_SDA (pin_H8)

// SPI
#define MICROPY_HW_SPI2_NSS (pin_B12)
#define MICROPY_HW_SPI2_SCK (pin_B13)
#define MICROPY_HW_SPI2_MISO (pin_B14)
#define MICROPY_HW_SPI2_MOSI (pin_B15)

// USRSW is pulled low. Pressing the button makes the input go high.
#define MICROPY_HW_USRSW_PIN (pin_A0)
#define MICROPY_HW_USRSW_PULL (GPIO_PULLDOWN)
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
#define MICROPY_HW_USRSW_PRESSED (1)

// LEDs
#define MICROPY_HW_LED1 (pyb_pin_LEDR) // red
#define MICROPY_HW_LED2 (pyb_pin_LEDG) // green
#define MICROPY_HW_LED3 (pyb_pin_LEDY) // yellow
#define MICROPY_HW_LED4 (pyb_pin_LEDB) // blue
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))

// WiFi SDMMC
/*
#define MICROPY_HW_SDIO_SDMMC (1)
#define MICROPY_HW_SDIO_CK (pin_C12)
#define MICROPY_HW_SDIO_CMD (pin_D2)
#define MICROPY_HW_SDIO_D0 (pin_C8)
#define MICROPY_HW_SDIO_D1 (pin_C9)
#define MICROPY_HW_SDIO_D2 (pin_C10)
#define MICROPY_HW_SDIO_D3 (pin_C11)
/
// SD Card SDMMC
/

#define MICROPY_HW_SDCARD_SDMMC (2)
#define MICROPY_HW_SDCARD_CK (pin_D6)
#define MICROPY_HW_SDCARD_CMD (pin_D7)
#define MICROPY_HW_SDCARD_D0 (pin_B14)
#define MICROPY_HW_SDCARD_D1 (pin_B15)
#define MICROPY_HW_SDCARD_D2 (pin_B3)
#define MICROPY_HW_SDCARD_D3 (pin_B4)
*/
// USB config
#define MICROPY_HW_USB_FS (1)
#define MICROPY_HW_USB_CDC_RX_DATA_SIZE (512)
#define MICROPY_HW_USB_CDC_TX_DATA_SIZE (512)
#define MICROPY_HW_USB_CDC_1200BPS_TOUCH (1)

// Bluetooth config
//#define MICROPY_HW_BLE_UART_ID (PYB_UART_7)
//#define MICROPY_HW_BLE_UART_BAUDRATE (115200)
//#define MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY (3000000)

// SDRAM
#define MICROPY_HW_SDRAM_SIZE (512 / 8 * 1024 * 1024) // 512 Mbit
#define MICROPY_HW_SDRAM_STARTUP_TEST (1)
#define MICROPY_HW_SDRAM_TEST_FAIL_ON_ERROR (true)

// Timing configuration for 200MHz/2=100MHz (10ns)
#define MICROPY_HW_SDRAM_CLOCK_PERIOD 2
#define MICROPY_HW_SDRAM_CAS_LATENCY 2
#define MICROPY_HW_SDRAM_FREQUENCY (100000) // 100 MHz
#define MICROPY_HW_SDRAM_TIMING_TMRD (2)
#define MICROPY_HW_SDRAM_TIMING_TXSR (8)
#define MICROPY_HW_SDRAM_TIMING_TRAS (6)
#define MICROPY_HW_SDRAM_TIMING_TRC (6)
#define MICROPY_HW_SDRAM_TIMING_TWR (2)
#define MICROPY_HW_SDRAM_TIMING_TRP (2)
#define MICROPY_HW_SDRAM_TIMING_TRCD (2)

#define MICROPY_HW_SDRAM_ROW_BITS_NUM 13
#define MICROPY_HW_SDRAM_MEM_BUS_WIDTH 32
#define MICROPY_HW_SDRAM_REFRESH_CYCLES 4096

#define MICROPY_HW_SDRAM_COLUMN_BITS_NUM 9
#define MICROPY_HW_SDRAM_INTERN_BANKS_NUM 4
#define MICROPY_HW_SDRAM_RPIPE_DELAY 0
#define MICROPY_HW_SDRAM_RBURST (1)
#define MICROPY_HW_SDRAM_WRITE_PROTECTION (0)

#define MICROPY_HW_SDRAM_AUTOREFRESH_NUM (8)
#define MICROPY_HW_SDRAM_BURST_LENGTH 1
#define MICROPY_HW_SDRAM_REFRESH_RATE (677) // ms

// SDRAM configuration
#define MICROPY_HW_FMC_SDCKE0 (pin_C3)
#define MICROPY_HW_FMC_SDNE0 (pin_C2)
#define MICROPY_HW_FMC_SDNBL0 (pin_E0)
#define MICROPY_HW_FMC_SDNBL1 (pin_E1)
#define MICROPY_HW_FMC_SDCLK (pin_G8)
#define MICROPY_HW_FMC_SDNCAS (pin_G15)
#define MICROPY_HW_FMC_SDNRAS (pin_F11)
#define MICROPY_HW_FMC_SDNWE (pin_C0)
#define MICROPY_HW_FMC_BA0 (pin_G4)
#define MICROPY_HW_FMC_BA1 (pin_G5)
#define MICROPY_HW_FMC_NBL0 (pin_E0)
#define MICROPY_HW_FMC_NBL1 (pin_E1)
#define MICROPY_HW_FMC_A0 (pin_F0)
#define MICROPY_HW_FMC_A1 (pin_F1)
#define MICROPY_HW_FMC_A2 (pin_F2)
#define MICROPY_HW_FMC_A3 (pin_F3)
#define MICROPY_HW_FMC_A4 (pin_F4)
#define MICROPY_HW_FMC_A5 (pin_F5)
#define MICROPY_HW_FMC_A6 (pin_F12)
#define MICROPY_HW_FMC_A7 (pin_F13)
#define MICROPY_HW_FMC_A8 (pin_F14)
#define MICROPY_HW_FMC_A9 (pin_F15)
#define MICROPY_HW_FMC_A10 (pin_G0)
#define MICROPY_HW_FMC_A11 (pin_G1)
#define MICROPY_HW_FMC_A12 (pin_G2)
#define MICROPY_HW_FMC_D0 (pin_D14)
#define MICROPY_HW_FMC_D1 (pin_D15)
#define MICROPY_HW_FMC_D2 (pin_D0)
#define MICROPY_HW_FMC_D3 (pin_D1)
#define MICROPY_HW_FMC_D4 (pin_E7)
#define MICROPY_HW_FMC_D5 (pin_E8)
#define MICROPY_HW_FMC_D6 (pin_E9)
#define MICROPY_HW_FMC_D7 (pin_E10)
#define MICROPY_HW_FMC_D8 (pin_E11)
#define MICROPY_HW_FMC_D9 (pin_E12)
#define MICROPY_HW_FMC_D10 (pin_E13)
#define MICROPY_HW_FMC_D11 (pin_E14)
#define MICROPY_HW_FMC_D12 (pin_E15)
#define MICROPY_HW_FMC_D13 (pin_D8)
#define MICROPY_HW_FMC_D14 (pin_D9)
#define MICROPY_HW_FMC_D15 (pin_D10)

// Ethernet via RMII
#define MICROPY_HW_ETH_MDC (pin_C1)
#define MICROPY_HW_ETH_MDIO (pin_A2)
#define MICROPY_HW_ETH_RMII_REF_CLK (pin_A1)
#define MICROPY_HW_ETH_RMII_CRS_DV (pin_A7)
#define MICROPY_HW_ETH_RMII_RXD0 (pin_C4)
#define MICROPY_HW_ETH_RMII_RXD1 (pin_C5)
#define MICROPY_HW_ETH_RMII_TX_EN (pin_G11)
#define MICROPY_HW_ETH_RMII_TXD0 (pin_G13)
#define MICROPY_HW_ETH_RMII_TXD1 (pin_G12)

#define MICROPY_HW_USB_VID 0x2341
#define MICROPY_HW_USB_PID 0x055B
#define MICROPY_HW_USB_PID_CDC_MSC (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC_HID (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_MSC (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC2_MSC (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC2 (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC3 (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC3_MSC (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC_MSC_HID (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC2_MSC_HID (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_PID_CDC3_MSC_HID (MICROPY_HW_USB_PID)
#define MICROPY_HW_USB_LANGID_STRING 0x409
Here is my config file

@dpgeorge
Copy link
Member

#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)

You can't use this object representation with double precision float (which the H750 has).

I suggest just removing this line and using the default object representation A. (You'll also need to remove the 4 lines after it as well.)

@klora-sun
Copy link
Author

#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)

You can't use this object representation with double precision float (which the H750 has).

I suggest just removing this line and using the default object representation A. (You'll also need to remove the 4 lines after it as well.)

OK, let me try

@klora-sun
Copy link
Author

#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)

You can't use this object representation with double precision float (which the H750 has).

I suggest just removing this line and using the default object representation A. (You'll also need to remove the 4 lines after it as well.)

Hello, after deletion, it does work properly. But I would like to ask this object representation with double precision float (which the H750 has).What does it mean, and how can I avoid similar problems the next time I want to continue compiling the firmware. Will there be a description of the questions in the data sheet of the chip?

@Coder311001
Copy link

Hello klora-sun, would you mind, if i ask you for your port for stm32h750 board?

@robert-hh robert-hh removed the bug label Aug 26, 2024
@klora-sun
Copy link
Author
klora-sun commented Aug 26, 2024 via email

@jonnor
Copy link
Contributor
jonnor commented Sep 1, 2024

The problem looks to have been resolved, will close this issue.
Information about the MicroPython object model can be found in https://docs.micropython.org/en/latest/develop/memorymgt.html#the-object-model and in py/mpconfig.h in the codebase.

@jonnor jonnor closed this as completed Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0