[STM32F401CE] debugging a new board definition [solved]
Re: [STM32F401CE] debugging a new board definition
There is definitely something wrong with the link step. The correct address is 0x08000000
It would be good to build with V=1 and see what the exact linking command is. It looks like you're not using the correct .ld file.
It would be good to build with V=1 and see what the exact linking command is. It looks like you're not using the correct .ld file.
Re: [STM32F401CE] debugging a new board definition
Here's the section of main.c I modified:
here's a compiler run with V=1:
Code: Select all
// At this point everything is fully configured and initialised.
// Run the main script from the current directory.
if ((reset_mode == 1 || reset_mode == 3) && pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
const char *main_py;
if (MP_STATE_PORT(pyb_config_main) == MP_OBJ_NULL) {
main_py = "main.py";
} else {
main_py = mp_obj_str_get_str(MP_STATE_PORT(pyb_config_main));
}
#if USE_FROZEN_BOOT_AND_MAIN
pyexec_frozen_module(main_py);
int ret = pyexec_file(main_py);
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
#else
mp_import_stat_t stat = mp_import_stat(main_py);
if (stat == MP_IMPORT_STAT_FILE) {
int ret = pyexec_file(main_py);
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
if (!ret) {
flash_error(3);
}
}
#endif
}
// Main script is finished, so now go into REPL mode.
// The REPL mode can change, or it can request a soft reset.
for (;;) {
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
if (pyexec_raw_repl() != 0) {
break;
}
} else {
if (pyexec_friendly_repl() != 0) {
break;
}
}
}
soft_reset_exit:
// soft reset
printf("PYB: sync filesystems\n");
storage_flush();
printf("PYB: soft reboot\n");
timer_deinit();
uart_deinit();
#if MICROPY_HW_ENABLE_CAN
can_deinit();
#endif
machine_deinit();
#if MICROPY_PY_THREAD
pyb_thread_deinit();
#endif
goto soft_reset;
}
Code: Select all
arm-none-eabi-gcc -I. -I../.. -Ibuild-PYFLEX_F401 -I../../lib/cmsis/inc -I../../lib/stm32lib/CMSIS/STM32F4xx/Include/ -I../../lib/stm32lib/STM32F4xx_HAL_Driver/Inc -Iusbdev/core/inc -Iusbdev/class/inc -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DSTM32F401xE -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mtune=cortex-m4 -mcpu=cortex-m4 -Os -DNDEBUG -Iboards/PYFLEX_F401 -DSTM32_HAL_H='<stm32f4xx_hal.h>' -DMICROPY_HW_VTOR=0x08000000 -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT -fsingle-precision-constant -Wdouble-promotion -fdata-sections -ffunction-sections -DMICROPY_MODULE_FROZEN_STR -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool -DMICROPY_MODULE_FROZEN_MPY -c -MD -o build-PYFLEX_F401/usbdev/class/src/usbd_msc_data.o usbdev/class/src/usbd_msc_data.c
CC build-PYFLEX_F401/pins_PYFLEX_F401.c
arm-none-eabi-gcc -I. -I../.. -Ibuild-PYFLEX_F401 -I../../lib/cmsis/inc -I../../lib/stm32lib/CMSIS/STM32F4xx/Include/ -I../../lib/stm32lib/STM32F4xx_HAL_Driver/Inc -Iusbdev/core/inc -Iusbdev/class/inc -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DSTM32F401xE -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mtune=cortex-m4 -mcpu=cortex-m4 -Os -DNDEBUG -Iboards/PYFLEX_F401 -DSTM32_HAL_H='<stm32f4xx_hal.h>' -DMICROPY_HW_VTOR=0x08000000 -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT -fsingle-precision-constant -Wdouble-promotion -fdata-sections -ffunction-sections -DMICROPY_MODULE_FROZEN_STR -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool -DMICROPY_MODULE_FROZEN_MPY -c -MD -o build-PYFLEX_F401/pins_PYFLEX_F401.o build-PYFLEX_F401/pins_PYFLEX_F401.c
CC build-PYFLEX_F401/frozen_mpy.c
arm-none-eabi-gcc -I. -I../.. -Ibuild-PYFLEX_F401 -I../../lib/cmsis/inc -I../../lib/stm32lib/CMSIS/STM32F4xx/Include/ -I../../lib/stm32lib/STM32F4xx_HAL_Driver/Inc -Iusbdev/core/inc -Iusbdev/class/inc -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DSTM32F401xE -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mtune=cortex-m4 -mcpu=cortex-m4 -Os -DNDEBUG -Iboards/PYFLEX_F401 -DSTM32_HAL_H='<stm32f4xx_hal.h>' -DMICROPY_HW_VTOR=0x08000000 -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT -fsingle-precision-constant -Wdouble-promotion -fdata-sections -ffunction-sections -DMICROPY_MODULE_FROZEN_STR -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool -DMICROPY_MODULE_FROZEN_MPY -c -MD -o build-PYFLEX_F401/build-PYFLEX_F401/frozen_mpy.o build-PYFLEX_F401/frozen_mpy.c
LINK build-PYFLEX_F401/firmware.elf
arm-none-eabi-ld -nostdlib -L boards -Map=build-PYFLEX_F401/firmware.map --cref --gc-sections -o build-PYFLEX_F401/firmware.elf build-PYFLEX_F401/py/mpstate.o build-PYFLEX_F401/py/nlr.o build-PYFLEX_F401/py/nlrx86.o build-PYFLEX_F401/py/nlrx64.o build-PYFLEX_F401/py/nlrthumb.o build-PYFLEX_F401/py/nlrxtensa.o build-PYFLEX_F401/py/nlrsetjmp.o build-PYFLEX_F401/py/malloc.o build-PYFLEX_F401/py/gc.o build-PYFLEX_F401/py/pystack.o build-PYFLEX_F401/py/qstr.o build-PYFLEX_F401/py/vstr.o build-PYFLEX_F401/py/mpprint.o build-PYFLEX_F401/py/unicode.o build-PYFLEX_F401/py/mpz.o build-PYFLEX_F401/py/reader.o build-PYFLEX_F401/py/lexer.o build-PYFLEX_F401/py/parse.o build-PYFLEX_F401/py/scope.o build-PYFLEX_F401/py/compile.o build-PYFLEX_F401/py/emitcommon.o build-PYFLEX_F401/py/emitbc.o build-PYFLEX_F401/py/asmbase.o build-PYFLEX_F401/py/asmx64.o build-PYFLEX_F401/py/emitnx64.o build-PYFLEX_F401/py/asmx86.o build-PYFLEX_F401/py/emitnx86.o build-PYFLEX_F401/py/asmthumb.o build-PYFLEX_F401/py/emitnthumb.o build-PYFLEX_F401/py/emitinlinethumb.o build-PYFLEX_F401/py/asmarm.o build-PYFLEX_F401/py/emitnarm.o build-PYFLEX_F401/py/asmxtensa.o build-PYFLEX_F401/py/emitnxtensa.o build-PYFLEX_F401/py/emitinlinextensa.o build-PYFLEX_F401/py/formatfloat.o build-PYFLEX_F401/py/parsenumbase.o build-PYFLEX_F401/py/parsenum.o build-PYFLEX_F401/py/emitglue.o build-PYFLEX_F401/py/persistentcode.o build-PYFLEX_F401/py/runtime.o build-PYFLEX_F401/py/runtime_utils.o build-PYFLEX_F401/py/scheduler.o build-PYFLEX_F401/py/nativeglue.o build-PYFLEX_F401/py/stackctrl.o build-PYFLEX_F401/py/argcheck.o build-PYFLEX_F401/py/warning.o build-PYFLEX_F401/py/map.o build-PYFLEX_F401/py/obj.o build-PYFLEX_F401/py/objarray.o build-PYFLEX_F401/py/objattrtuple.o build-PYFLEX_F401/py/objbool.o build-PYFLEX_F401/py/objboundmeth.o build-PYFLEX_F401/py/objcell.o build-PYFLEX_F401/py/objclosure.o build-PYFLEX_F401/py/objcomplex.o build-PYFLEX_F401/py/objdeque.o build-PYFLEX_F401/py/objdict.o build-PYFLEX_F401/py/objenumerate.o build-PYFLEX_F401/py/objexcept.o build-PYFLEX_F401/py/objfilter.o build-PYFLEX_F401/py/objfloat.o build-PYFLEX_F401/py/objfun.o build-PYFLEX_F401/py/objgenerator.o build-PYFLEX_F401/py/objgetitemiter.o build-PYFLEX_F401/py/objint.o build-PYFLEX_F401/py/objint_longlong.o build-PYFLEX_F401/py/objint_mpz.o build-PYFLEX_F401/py/objlist.o build-PYFLEX_F401/py/objmap.o build-PYFLEX_F401/py/objmodule.o build-PYFLEX_F401/py/objobject.o build-PYFLEX_F401/py/objpolyiter.o build-PYFLEX_F401/py/objproperty.o build-PYFLEX_F401/py/objnone.o build-PYFLEX_F401/py/objnamedtuple.o build-PYFLEX_F401/py/objrange.o build-PYFLEX_F401/py/objreversed.o build-PYFLEX_F401/py/objset.o build-PYFLEX_F401/py/objsingleton.o build-PYFLEX_F401/py/objslice.o build-PYFLEX_F401/py/objstr.o build-PYFLEX_F401/py/objstrunicode.o build-PYFLEX_F401/py/objstringio.o build-PYFLEX_F401/py/objtuple.o build-PYFLEX_F401/py/objtype.o build-PYFLEX_F401/py/objzip.o build-PYFLEX_F401/py/opmethods.o build-PYFLEX_F401/py/sequence.o build-PYFLEX_F401/py/stream.o build-PYFLEX_F401/py/binary.o build-PYFLEX_F401/py/builtinimport.o build-PYFLEX_F401/py/builtinevex.o build-PYFLEX_F401/py/builtinhelp.o build-PYFLEX_F401/py/modarray.o build-PYFLEX_F401/py/modbuiltins.o build-PYFLEX_F401/py/modcollections.o build-PYFLEX_F401/py/modgc.o build-PYFLEX_F401/py/modio.o build-PYFLEX_F401/py/modmath.o build-PYFLEX_F401/py/modcmath.o build-PYFLEX_F401/py/modmicropython.o build-PYFLEX_F401/py/modstruct.o build-PYFLEX_F401/py/modsys.o build-PYFLEX_F401/py/moduerrno.o build-PYFLEX_F401/py/modthread.o build-PYFLEX_F401/py/vm.o build-PYFLEX_F401/py/bc.o build-PYFLEX_F401/py/showbc.o build-PYFLEX_F401/py/repl.o build-PYFLEX_F401/py/smallint.o build-PYFLEX_F401/py/frozenmod.o build-PYFLEX_F401/extmod/moductypes.o build-PYFLEX_F401/extmod/modujson.o build-PYFLEX_F401/extmod/modure.o build-PYFLEX_F401/extmod/moduzlib.o build-PYFLEX_F401/extmod/moduheapq.o build-PYFLEX_F401/extmod/modutimeq.o build-PYFLEX_F401/extmod/moduhashlib.o build-PYFLEX_F401/extmod/modubinascii.o build-PYFLEX_F401/extmod/virtpin.o build-PYFLEX_F401/extmod/machine_mem.o build-PYFLEX_F401/extmod/machine_pinbase.o build-PYFLEX_F401/extmod/machine_signal.o build-PYFLEX_F401/extmod/machine_pulse.o build-PYFLEX_F401/extmod/machine_i2c.o build-PYFLEX_F401/extmod/machine_spi.o build-PYFLEX_F401/extmod/modussl_axtls.o build-PYFLEX_F401/extmod/modussl_mbedtls.o build-PYFLEX_F401/extmod/modurandom.o build-PYFLEX_F401/extmod/moduselect.o build-PYFLEX_F401/extmod/modwebsocket.o build-PYFLEX_F401/extmod/modwebrepl.o build-PYFLEX_F401/extmod/modframebuf.o build-PYFLEX_F401/extmod/vfs.o build-PYFLEX_F401/extmod/vfs_reader.o build-PYFLEX_F401/extmod/vfs_fat.o build-PYFLEX_F401/extmod/vfs_fat_diskio.o build-PYFLEX_F401/extmod/vfs_fat_file.o build-PYFLEX_F401/extmod/utime_mphal.o build-PYFLEX_F401/extmod/uos_dupterm.o build-PYFLEX_F401/lib/embed/abort_.o build-PYFLEX_F401/lib/utils/printf.o build-PYFLEX_F401/build-PYFLEX_F401/frozen.o build-PYFLEX_F401/build-PYFLEX_F401/frozen_mpy.o build-PYFLEX_F401/lib/libc/string0.o build-PYFLEX_F401/lib/oofatfs/ff.o build-PYFLEX_F401/lib/oofatfs/option/unicode.o build-PYFLEX_F401/lib/mp-readline/readline.o build-PYFLEX_F401/lib/netutils/netutils.o build-PYFLEX_F401/lib/timeutils/timeutils.o build-PYFLEX_F401/lib/utils/pyexec.o build-PYFLEX_F401/lib/utils/interrupt_char.o build-PYFLEX_F401/lib/utils/sys_stdio_mphal.o build-PYFLEX_F401/lib/libm/math.o build-PYFLEX_F401/lib/libm/thumb_vfp_sqrtf.o build-PYFLEX_F401/lib/libm/acoshf.o build-PYFLEX_F401/lib/libm/asinfacosf.o build-PYFLEX_F401/lib/libm/asinhf.o build-PYFLEX_F401/lib/libm/atan2f.o build-PYFLEX_F401/lib/libm/atanf.o build-PYFLEX_F401/lib/libm/atanhf.o build-PYFLEX_F401/lib/libm/ef_rem_pio2.o build-PYFLEX_F401/lib/libm/erf_lgamma.o build-PYFLEX_F401/lib/libm/fmodf.o build-PYFLEX_F401/lib/libm/kf_cos.o build-PYFLEX_F401/lib/libm/kf_rem_pio2.o build-PYFLEX_F401/lib/libm/kf_sin.o build-PYFLEX_F401/lib/libm/kf_tan.o build-PYFLEX_F401/lib/libm/log1pf.o build-PYFLEX_F401/lib/libm/nearbyintf.o build-PYFLEX_F401/lib/libm/sf_cos.o build-PYFLEX_F401/lib/libm/sf_erf.o build-PYFLEX_F401/lib/libm/sf_frexp.o build-PYFLEX_F401/lib/libm/sf_ldexp.o build-PYFLEX_F401/lib/libm/sf_modf.o build-PYFLEX_F401/lib/libm/sf_sin.o build-PYFLEX_F401/lib/libm/sf_tan.o build-PYFLEX_F401/lib/libm/wf_lgamma.o build-PYFLEX_F401/lib/libm/wf_tgamma.o build-PYFLEX_F401/extmod/modonewire.o build-PYFLEX_F401/drivers/bus/softspi.o build-PYFLEX_F401/drivers/bus/softqspi.o build-PYFLEX_F401/drivers/memory/spiflash.o build-PYFLEX_F401/drivers/dht/dht.o build-PYFLEX_F401/main.o build-PYFLEX_F401/system_stm32.o build-PYFLEX_F401/stm32_it.o build-PYFLEX_F401/usbd_conf.o build-PYFLEX_F401/usbd_desc.o build-PYFLEX_F401/usbd_cdc_interface.o build-PYFLEX_F401/usbd_hid_interface.o build-PYFLEX_F401/usbd_msc_storage.o build-PYFLEX_F401/mphalport.o build-PYFLEX_F401/mpthreadport.o build-PYFLEX_F401/irq.o build-PYFLEX_F401/pendsv.o build-PYFLEX_F401/systick.o build-PYFLEX_F401/pybthread.o build-PYFLEX_F401/timer.o build-PYFLEX_F401/led.o build-PYFLEX_F401/pin.o build-PYFLEX_F401/pin_defs_stm32.o build-PYFLEX_F401/pin_named_pins.o build-PYFLEX_F401/bufhelper.o build-PYFLEX_F401/dma.o build-PYFLEX_F401/i2c.o build-PYFLEX_F401/spi.o build-PYFLEX_F401/qspi.o build-PYFLEX_F401/uart.o build-PYFLEX_F401/can.o build-PYFLEX_F401/usb.o build-PYFLEX_F401/wdt.o build-PYFLEX_F401/gccollect.o build-PYFLEX_F401/help.o build-PYFLEX_F401/machine_i2c.o build-PYFLEX_F401/modmachine.o build-PYFLEX_F401/modpyb.o build-PYFLEX_F401/modstm.o build-PYFLEX_F401/moduos.o build-PYFLEX_F401/modutime.o build-PYFLEX_F401/modusocket.o build-PYFLEX_F401/modnetwork.o build-PYFLEX_F401/extint.o build-PYFLEX_F401/usrsw.o build-PYFLEX_F401/rng.o build-PYFLEX_F401/rtc.o build-PYFLEX_F401/flash.o build-PYFLEX_F401/flashbdev.o build-PYFLEX_F401/spibdev.o build-PYFLEX_F401/storage.o build-PYFLEX_F401/sdcard.o build-PYFLEX_F401/fatfs_port.o build-PYFLEX_F401/lcd.o build-PYFLEX_F401/accel.o build-PYFLEX_F401/servo.o build-PYFLEX_F401/dac.o build-PYFLEX_F401/adc.o build-PYFLEX_F401/boards/startup_stm32f4.o build-PYFLEX_F401/resethandler.o build-PYFLEX_F401/gchelper.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dac.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dac_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.o build-PYFLEX_F401/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.o build-PYFLEX_F401/usbdev/core/src/usbd_core.o build-PYFLEX_F401/usbdev/core/src/usbd_ctlreq.o build-PYFLEX_F401/usbdev/core/src/usbd_ioreq.o build-PYFLEX_F401/usbdev/class/src/usbd_cdc_msc_hid.o build-PYFLEX_F401/usbdev/class/src/usbd_msc_bot.o build-PYFLEX_F401/usbdev/class/src/usbd_msc_scsi.o build-PYFLEX_F401/usbdev/class/src/usbd_msc_data.o build-PYFLEX_F401/pins_PYFLEX_F401.o /usr/local/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu/libgcc.a
arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 00008000
arm-none-eabi-size build-PYFLEX_F401/firmware.elf
text data bss dec hex filename
0 0 0 0 0 build-PYFLEX_F401/firmware.elf
Create build-PYFLEX_F401/firmware.dfu
arm-none-eabi-objcopy -O binary -j .isr_vector -j .text -j .data build-PYFLEX_F401/firmware.elf build-PYFLEX_F401/firmware.bin
GEN build-PYFLEX_F401/firmware.hex
arm-none-eabi-objcopy -O ihex build-PYFLEX_F401/firmware.elf build-PYFLEX_F401/firmware.hex
python ../../tools/dfu.py -b 0x08000000:build-PYFLEX_F401/firmware.bin build-PYFLEX_F401/firmware.dfu
/home/john/Documents/EEProjects/circuitboards/culture_shock/code_PYFLEX_F401
John Griessen blog.kitmatic.com
Re: [STM32F401CE] debugging a new board definition
Here's the other part I modified in main.c:
First I did a git pull, then checkout -b stm32_frozen to create a new branch,
then modified the file main.c
Here is the mpconfigboard.mk file I used:
I'm trying NUCLEO_F401RE with this repo. To see if it will compile all the way.
First I did a git pull, then checkout -b stm32_frozen to create a new branch,
then modified the file main.c
Code: Select all
// run boot.py, if it exists
// TODO perhaps have pyb.reboot([bootpy]) function to soft-reboot and execute custom boot.py
if (reset_mode == 1 || reset_mode == 3) {
const char *boot_py = "boot.py";
#define USE_FROZEN_BOOT_AND_MAIN 1
#if USE_FROZEN_BOOT_AND_MAIN
pyexec_frozen_module(boot_py);
#else
mp_import_stat_t stat = mp_import_stat(boot_py);
if (stat == MP_IMPORT_STAT_FILE) {
int ret = pyexec_file(boot_py);
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
if (!ret) {
flash_error(4);
}
}
#endif
}
// turn boot-up LEDs off
#if !defined(MICROPY_HW_LED2)
// If there is only one LED on the board then it's used to signal boot-up
// and so we turn it off here. Otherwise LED(1) is used to indicate dirty
// flash cache and so we shouldn't change its state.
Code: Select all
MCU_SERIES = f4
CMSIS_MCU = STM32F401xE
AF_FILE = boards/stm32f401_af.csv
LD_FILE = boards/stm32f401xe.ld
John Griessen blog.kitmatic.com
Re: [STM32F401CE] debugging a new board definition
It looks like the mainstream changed mpconfigboard.mk and you should have: That was from the NUCELO_F401RE/mpconfigboard.mk file
Code: Select all
MCU_SERIES = f4
CMSIS_MCU = STM32F401xE
AF_FILE = boards/stm32f401_af.csv
LD_FILES = boards/stm32f401xe.ld boards/common_ifs.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000
Re: [STM32F401CE] debugging a new board definition
I fixed the changes up like NUCLEO_F401RE and compile:
ll build-PYFLEX_F401/fir*
-rwxr-xr-x 1 john john 14792 Apr 10 17:37 build-PYFLEX_F401/firmware0.bin
-rwxr-xr-x 1 john john 283376 Apr 10 17:37 build-PYFLEX_F401/firmware1.bin
-rw-r--r-- 1 john john 298485 Apr 10 17:37 build-PYFLEX_F401/firmware.dfu
Will test loading it with openocd now.
ll build-PYFLEX_F401/fir*
-rwxr-xr-x 1 john john 14792 Apr 10 17:37 build-PYFLEX_F401/firmware0.bin
-rwxr-xr-x 1 john john 283376 Apr 10 17:37 build-PYFLEX_F401/firmware1.bin
-rw-r--r-- 1 john john 298485 Apr 10 17:37 build-PYFLEX_F401/firmware.dfu
Will test loading it with openocd now.
John Griessen blog.kitmatic.com
Re: [STM32F401CE] debugging a new board definition
My pintest.py program is not running successfully on the target. PA5, PB0, PB1, PB2 not toggling.
this is loaded by the same method as miniblink C programs load and run with positive results on these same GPIOs.
Is there any way to double check the putting-together of main.py, boot.py and main.c?
Here is my pintest.py program:
And here is boot.py:
this is loaded by the same method as miniblink C programs load and run with positive results on these same GPIOs.
Is there any way to double check the putting-together of main.py, boot.py and main.c?
Here is my pintest.py program:
Code: Select all
import pyb
from pyb import Timer
import micropython
import stm
micropython.alloc_emergency_exception_buf(100)
# Use with pyb.freq(84000000) and prescaler=20 for .25 usec timer ticks.
xfmr_pulse_period = 14000000 # = (usec * 4) 700ms
xfmr_pulse_w = 900000 # = (usec * 4) 225ms
pos_pulse_total = 0
pos_pulse_burstlen = 50007
neg_pulse_total = 0
neg_pulse_burstlen = 50007
# Timer 2 to give .25 usec timer ticks counting up:
t2 = pyb.Timer(2, prescaler=20, period=xfmr_pulse_period, mode=Timer.UP)
# xfmr pulse half_cycle timing. (OC rollover callback)
# output and interrrupt. Compare generates interrupt:
t2ch3 = t2.channel(3, pyb.Timer.OC_TOGGLE, compare=xfmr_pulse_period,
polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.LED_GREEN)
t2ch2 = t2.channel(2, pyb.Timer.OC_TOGGLE, compare=xfmr_pulse_period,
polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.LED_YELLOW)
# Define already set up pins so they can be read with a pin reference like: pin8.value() on the fly.
pin8 = pyb.Pin.board.LED_GREEN
pin9 = pyb.Pin.board.LED_YELLOW
# Define pins so they can be set with a pin reference like: pin10.value(1) on the fly.
pinA5 = pyb.Pin('PA5', pyb.Pin.OUT_PP)
pinB0 = pyb.Pin('PB0', pyb.Pin.OUT_PP)
pinB1 = pyb.Pin('PB1', pyb.Pin.OUT_PP)
pinB2 = pyb.Pin('PB2', pyb.Pin.OUT_PP)
pinB3 = pyb.Pin('PB3', pyb.Pin.OUT_PP)
pinB4 = pyb.Pin('PB4', pyb.Pin.OUT_PP)
pinB5 = pyb.Pin('PB5', pyb.Pin.OUT_PP)
pinB6 = pyb.Pin('PB6', pyb.Pin.OUT_PP)
pinB7 = pyb.Pin('PB7', pyb.Pin.OUT_PP)
pinB10 = pyb.Pin('PB10', pyb.Pin.OUT_PP)
pinB13 = pyb.Pin('PB13', pyb.Pin.OUT_PP)
pinB14 = pyb.Pin('PB14', pyb.Pin.OUT_PP)
pinB15 = pyb.Pin('PB15', pyb.Pin.OUT_PP)
for i in range(30):
pinA5.value(1)
time.sleep(0.2)
pinA5.value(0)
pinB0.value(1)
time.sleep(0.2)
pinB0.value(0)
pinB1.value(1)
time.sleep(0.2)
pinB1.value(0)
pinB2.value(1)
time.sleep(0.2)
pinB2.value(0)
pinB3.value(1)
time.sleep(0.2)
pinB3.value(0)
pinB4.value(1)
time.sleep(0.2)
pinB4.value(0)
pinB5.value(1)
time.sleep(0.2)
pinB5.value(0)
pinB6.value(1)
time.sleep(0.2)
pinB6.value(0)
pinB7.value(1)
time.sleep(0.2)
pinB7.value(0)
pinB10.value(1)
time.sleep(0.2)
pinB10.value(0)
pinB13.value(1)
time.sleep(0.2)
pinB13.value(0)
pinB14.value(1)
time.sleep(0.2)
pinB14.value(0)
pinB15.value(1)
time.sleep(0.2)
pinB15.value(0)
Code: Select all
# boot.py -- run on boot-up
import machine
import pyb
pyb.usb_mode(None)
uart = pyb.UART(2, 9600)
uart.write(b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA'b'\xAA')
#pyb.repl_uart(uart)
pyb.freq(84000000)
pyb.main('pintest.py')
John Griessen blog.kitmatic.com
Re: [STM32F401CE] debugging a new board definition
I would remove the call to pyb.freq() just in case (none of the other boards do this). I would stick with the stock boot.py
It looks like you've got a really complicated test. I would start off with something super simple like:
You can verify what files have been frozen by looking inside frozen_mpy.c in your build-BOARDNAME directory. Near the end of the file you should see mp_frozen_mpy_names followed by a list of filenames. Those filenames are the frozen files that are included in your image. Make sure boot.py, main.py and your test program are all listed.
It looks like you've got a really complicated test. I would start off with something super simple like:
Code: Select all
led = pyb.LED(2)
while True:
led.toggle()
pyb.delay(1000)
Re: [STM32F401CE] debugging a new board definition
And in fact, when things start going amuck, I'll modify main.c to flash the LED from C code before it even gets to executing boot.py.
Re: [STM32F401CE] debugging a new board definition
I'm missing main.py, but I had boot.py calling pintest.py. I'll try your suggestions of super simple soon.you should see mp_frozen_mpy_names followed by a list of filenames. Those filenames are the frozen files that are included in your image. Make sure boot.py, main.py and your test program are all listed.
John Griessen blog.kitmatic.com
Re: [STM32F401CE] debugging a new board definition
I tried boot.py and main.py simplifying and nothing.
Maybe there is something wrong with my repo. It's years old. Does it have git submodules?
I'm thinking of copying out my stuff, cloning a new repo, and putting my stuff back and trying again.
I did get the repo fresh and noticed it pull in submodule fresh libstm32 or some such.
Then I compiled with good looking results, frozen files included listed correctly, but still no flashing LED.
Your method of adding a GPIO out in C language in main.c might be a good next step.
this hardware works to flash LEDs using miniblink and not changing any wires -- same hookup to SWD pins VCC and ground
as used to flash miniblink with openocd and FT2232H is used for flashing firmware0.bin firmware1.bin.
Here is openocd script used:
Maybe there is something wrong with my repo. It's years old. Does it have git submodules?
I'm thinking of copying out my stuff, cloning a new repo, and putting my stuff back and trying again.
I did get the repo fresh and noticed it pull in submodule fresh libstm32 or some such.
Then I compiled with good looking results, frozen files included listed correctly, but still no flashing LED.
Your method of adding a GPIO out in C language in main.c might be a good next step.
this hardware works to flash LEDs using miniblink and not changing any wires -- same hookup to SWD pins VCC and ground
as used to flash miniblink with openocd and FT2232H is used for flashing firmware0.bin firmware1.bin.
Here is openocd script used:
Code: Select all
#!/bin/bash
# program_openocd_stlink_STM32F401CE.sh
openocd -f /home/john/Documents/EEProjects/circuitboards/culture_shock/code_PYFLEX_F401/minimodule-swd-on-ch1.cfg -f target/stm32f4x.cfg -c "program ./PYFLEX_F401_firmware0.bin 0x08000000 verify; program ./PYFLEX_F401_firmware1.bin 0x08020000 verify reset exit"
John Griessen blog.kitmatic.com