[ell-i-developers] changes in stlink to get our nucleo flashed in ubuntu

  • From: Eero Hakala <eero.k.hakala@xxxxxxxxx>
  • To: ell-i-developers <ell-i-developers@xxxxxxxxxxxxx>
  • Date: Tue, 2 Sep 2014 09:13:17 +0300

Hi, I made some changes in stlink to get our nucleo flashed - could
somebody please review this because I have not been able to figure out all
details (they are well hidden in st-pages).


This is the general process of setting up the environment:
git@xxxxxxxxxx:texane/stlink.git

then in stlink directory
./autogen
./configure
make

And voila, all ready: st-util and st-flash look like functional - some
probelms still with st-info and st-term...


Changes to be revied are in src/stlink-common.c and src/stlink-common.h:

This is what diff gives out
eero@tkone:~/swe/sula$ diff stori/src/stlink-common.h
stlink/src/stlink-common.h
128a129
> #define STM32_CHIPID_F334           0x438
326a328,338
>             .bootrom_base = 0x1ffff000,
>             .bootrom_size = 0x800
>         },
>         {
>             // This is STK32F334R8 device from STM32 nucleo board
>             // Support based on 303 above (37x and 30x have same memory
map)
>             .chip_id = STM32_CHIPID_F334,
>             .description = "ähväkolomonen device",
>             .flash_size_reg = 0x1ffff7cc,
>             .flash_pagesize = 0x800,
>             .sram_size = 0x4000,

But its in fact wrong because I just added an elemnt in the data structure,
not something in between as diff thinks, the change is just an addition as
below:
addition from 331 to 341
        {
            // This is STK32F334R8 device from STM32 nucleo board
            // Support based on 303 above (37x and 30x have same memory map)
            .chip_id = STM32_CHIPID_F334,
            .description = "ähväkolomonen device",
            .flash_size_reg = 0x1ffff7cc,
            .flash_pagesize = 0x800,
            .sram_size = 0x4000,
            .bootrom_base = 0x1ffff000,
            .bootrom_size = 0x800
        },

Then I just added the missing chip info to the most suitable place every
time that st-flash complained something! As I don't know all differences
these additions might be in a wrong place!

eero@tkone:~/swe/sula$ diff stori/src/stlink-common.c
stlink/src/stlink-common.c
1130c1130,1131
<             || sl->chip_id == STM32_CHIPID_F37x) {
---
>             || sl->chip_id == STM32_CHIPID_F37x
>             || sl->chip_id == STM32_CHIPID_F334) {
1361c1362
<     } else if (sl->core_id == STM32VL_CORE_ID || sl->chip_id ==
STM32_CHIPID_F3  || sl->chip_id == STM32_CHIPID_F37x) {
---
>     } else if (sl->core_id == STM32VL_CORE_ID || sl->chip_id ==
STM32_CHIPID_F3  || sl->chip_id == STM32_CHIPID_F37x || sl->chip_id ==
STM32_CHIPID_F334) {
1658c1659
<     } else if (sl->core_id == STM32VL_CORE_ID || sl->core_id ==
STM32F0_CORE_ID || sl->chip_id == STM32_CHIPID_F3  || sl->chip_id ==
STM32_CHIPID_F37x) {
---
>     } else if (sl->core_id == STM32VL_CORE_ID || sl->core_id ==
STM32F0_CORE_ID || sl->chip_id == STM32_CHIPID_F3  || sl->chip_id ==
STM32_CHIPID_F37x || sl->chip_id == STM32_CHIPID_F334) {
1762c1763
<     } else if (sl->core_id == STM32VL_CORE_ID || sl->core_id ==
STM32F0_CORE_ID || sl->chip_id == STM32_CHIPID_F3  || sl->chip_id ==
STM32_CHIPID_F37x) {
---
>     } else if (sl->core_id == STM32VL_CORE_ID || sl->core_id ==
STM32F0_CORE_ID || sl->chip_id == STM32_CHIPID_F3  || sl->chip_id ==
STM32_CHIPID_F37x || sl->chip_id == STM32_CHIPID_F334) {
1794c1795
< #define WAIT_ROUNDS 10000
---
> #define WAIT_ROUNDS 100000
1821c1822
<     } else if (sl->core_id == STM32VL_CORE_ID || sl->core_id ==
STM32F0_CORE_ID || sl->chip_id == STM32_CHIPID_F3  || sl->chip_id ==
STM32_CHIPID_F37x) {
---
>     } else if (sl->core_id == STM32VL_CORE_ID || sl->core_id ==
STM32F0_CORE_ID || sl->chip_id == STM32_CHIPID_F3  || sl->chip_id ==
STM32_CHIPID_F37x || sl->chip_id == STM32_CHIPID_F334) {


-eero-

PS find below output from st-util and st-link


./st-flash write
/home/eero/swe/RIOT/examples/hello-world/bin/stm32f3discovery/hello-world.hex
0x08000000
2014-09-02T08:44:17 INFO src/stlink-common.c: Loading device parameters....
2014-09-02T08:44:17 INFO src/stlink-common.c: Device connected is:
ähväkolomonen device, id 0x10016438
2014-09-02T08:44:17 INFO src/stlink-common.c: SRAM size: 0x4000 bytes (16
KiB), Flash: 0x10000 bytes (64 KiB) in pages of 2048 bytes
2014-09-02T08:44:17 INFO src/stlink-common.c: Attempting to write 36044
(0x8ccc) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08008800 erased
2014-09-02T08:44:17 INFO src/stlink-common.c: Finished erasing 18 pages of
2048 (0x800) bytes
2014-09-02T08:44:17 INFO src/stlink-common.c: Starting Flash write for
VL/F0 core id
2014-09-02T08:44:17 INFO src/stlink-common.c: Successfully loaded flash
loader in sram
 17/17 pages written
2014-09-02T08:44:19 INFO src/stlink-common.c: Starting verification of
write complete
2014-09-02T08:44:20 INFO src/stlink-common.c: Flash written and verified!
jolly good!

eero@tkone:~/swe/sula/stlink$ ./st-util -v99
2014-09-02T08:45:09 DEBUG src/stlink-common.c: stlink current mode: debug
(jtag or swd)
2014-09-02T08:45:09 DEBUG src/stlink-common.c: stlink current mode: debug
(jtag or swd)
2014-09-02T08:45:09 INFO src/stlink-common.c: Loading device parameters....
2014-09-02T08:45:09 DEBUG src/stlink-common.c: *** stlink_core_id ***
2014-09-02T08:45:09 DEBUG src/stlink-common.c: core_id = 0x2ba01477
2014-09-02T08:45:09 DEBUG src/stlink-common.c: *** stlink_read_debug32
10016438 is 0xe0042000
2014-09-02T08:45:09 DEBUG src/stlink-common.c: *** stlink_read_debug32
ffff0040 is 0x1ffff7cc
2014-09-02T08:45:09 INFO src/stlink-common.c: Device connected is:
ähväkolomonen device, id 0x10016438
2014-09-02T08:45:09 INFO src/stlink-common.c: SRAM size: 0x4000 bytes (16
KiB), Flash: 0x10000 bytes (64 KiB) in pages of 2048 bytes
2014-09-02T08:45:09 DEBUG src/stlink-common.c: *** looking up stlink version
2014-09-02T08:45:09 DEBUG src/stlink-common.c: st vid         = 0x0483
(expect 0x0483)
2014-09-02T08:45:09 DEBUG src/stlink-common.c: stlink pid     = 0x374b
2014-09-02T08:45:09 DEBUG src/stlink-common.c: stlink version = 0x2
2014-09-02T08:45:09 DEBUG src/stlink-common.c: jtag version   = 0x14
2014-09-02T08:45:09 DEBUG src/stlink-common.c: swim version   = 0x4
2014-09-02T08:45:09 DEBUG src/stlink-common.c: *** stlink_reset ***
2014-09-02T08:45:09 INFO gdbserver/gdb-server.c: Chip ID is 00000438, Core
ID is  2ba01477.
2014-09-02T08:45:09 DEBUG src/stlink-common.c: *** reading target voltage
2014-09-02T08:45:09 DEBUG src/stlink-common.c: target voltage = 3232mV
2014-09-02T08:45:09 INFO gdbserver/gdb-server.c: Target voltage is 3232 mV.
2014-09-02T08:45:09 INFO gdbserver/gdb-server.c: Listening at *:4242...
^C2014-09-02T08:45:14 DEBUG src/stlink-common.c: *** stlink_run ***
2014-09-02T08:45:14 DEBUG src/stlink-common.c: *** stlink_exit_debug_mode
***
2014-09-02T08:45:14 DEBUG src/stlink-common.c: *** stlink_write_debug32
a05f0000 to 0xe000edf0
2014-09-02T08:45:14 DEBUG src/stlink-common.c: *** stlink_close ***

Other related posts: