Skip to main content
Mateusz Grosik
Associate II
March 3, 2017
Question

Secondary bootloader

  • March 3, 2017
  • 7 replies
  • 3466 views
Posted on March 03, 2017 at 23:31

Hello

I try make a secondary bootloader. I must send my code program from stm32f103 board to SPC560P board via CAN, and program should downlaod by BAM to flash.

I used transceivers. I know i should make user.ld, but can you explain me how?

I make some standalone_ram.ld in ghs, here is my file, it is correct to ran uC in BAM mode?

MEMORY {

// 384k Internal Flash

flash_rsvd1 : ORIGIN = 0x00000000, LENGTH = 8

flash_memory : ORIGIN = ., LENGTH = 384K-8

flash_rsvd2 : ORIGIN = ., LENGTH = 0

// 24KB of internal SRAM starting at 0x40000000

dram_rsvd1 : ORIGIN = 0x40000000, LENGTH = 0

dram_reset : ORIGIN = ., LENGTH = 0

dram_memory : ORIGIN = ., LENGTH = 24K-256

heap_reserve:origin = ., LENGTH = 8K

stack_reserve:origin = ., LENGTH = 8K

dram_rsvd2 : ORIGIN = ., LENGTH = 16

}

DEFAULTS {

stack_reserve = 4K

heap_reserve = 4K

}

//

// Program layout for running out of RAM.

//

//

SECTIONS

{

.PPC.EMB.sdata0 ABS : > dram_memory

.PPC.EMB.sbss0 CLEAR ABS : > .

.text : > dram_memory

.vletext : > .

.syscall : > .

.rchw NOCHECKSUM : > .

.secinfo : > .

.rodata : > .

.sdata2 : > .

.fixaddr : > .

.fixtype : > .

.sdabase ALIGN(16) : > dram_memory

.sdata : > .

.sbss : > .

.data : > .

.bss : > .

.heap ALIGN(16) PAD(heap_reserve) : > .

.stack ALIGN(16) PAD(stack_reserve) : > .

//

// These special symbols mark the bounds of RAM and ROM memory.

// They are used by the MULTI debugger.

//

__ghs_ramstart = MEMADDR(dram_rsvd1);

__ghs_ramend = MEMENDADDR(dram_memory);

__ghs_romstart = MEMADDR(flash_rsvd1);

__ghs_romend = MEMENDADDR(flash_rsvd2);

_ram_image_heap = ENDADDR (heap_reserve);

_ram_image_stack = ENDADDR (stack_reserve);

_ram_image_end = ENDADDR (.bss);

}

Best regards

Mateusz

    This topic has been closed for replies.

    7 replies

    procolo
    Visitor II
    March 20, 2017
    Posted on March 20, 2017 at 15:10

    Hello,

    I'm working on a test application allowing to get code from can and program it to flash. I will come back asap.

    My Idea is to run a boot-loader which will receive code via CAN , flash code to a given address and set the boot to another flash address so at next boot , board will run this code. Does this match your requirements?

    question:

    is the following request related to the same problem ?:

    https://community.st.com/0D50X00009XkYZ5SAN

    Mateusz Grosik
    Associate II
    March 22, 2017
    Posted on March 22, 2017 at 14:27

    Yes, sounds good. I should sending a binary code from STM32F103 to SPC560 using CAN. And SPC560 using BAM have to program a flash. SPC560 board have a transceiver and it received binary image. I will be grateful for your help.

    Best regards.

    Mateusz Raczkowski

    Mateusz Grosik
    Associate II
    March 22, 2017
    Posted on March 22, 2017 at 14:28

    And now i trying do it on SPC560P disp board

    procolo
    Visitor II
    March 24, 2017
    Posted on March 24, 2017 at 16:35

    Hi,

    Attached application for Discovery Pictus is a SW BAM.

    it receives data from CAN bus (speed 300khz) , load to RAM and the jump

    this app is tested using spc5connect with spc5 flasher.

    You can start fromhere, implementing the same protocol on your STM32 and the modify the BAM to write in flash instead of RAM (if needed) using the flash component.

    Please be sure to use the latest version of spc5Studio (5.2.3)

    Regards,

    Procolo

    ________________

    Attachments :

    SPC560Pxx_SW_BAM.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyks&d=%2Fa%2F0X0000000bC1%2FvRQdu3AEIuMqLPs.4oltDPa7Zc4u5nVPqcdFWL1UZ44&asPdf=false
    Mateusz Grosik
    Associate II
    March 24, 2017
    Posted on March 24, 2017 at 19:52

    Thanks a lot, i have one more question. When i useing CAN bus, i need to set a password?

    Something like this in chapter 5.2: 

    http://www.st.com/content/ccc/resource/technical/document/reference_manual/cf/ad/d5/76/55/1f/49/de/CD00192452.pdf/files/CD00192452.pdf/jcr:content/translations/en.CD00192452.pdf

      

    In here i see password: 0xFEED_FACE_CAFE_BEEF

    I can change this using external app? 

    Regard

    Mateusz

    procolo
    Visitor II
    March 27, 2017
    Posted on March 27, 2017 at 08:57

    Yes of course,

    you can implement your own StartPasswordCheck(uint64_t *passwordptr ) function.

    This code implements BAM via SW but you can modify it as per you needs.

    Regards,

    Procolo

    Mateusz Grosik
    Associate II
    March 27, 2017
    Posted on March 27, 2017 at 11:38

    Thanks, and when i use BAM and CAN i should set jumper like this: ABS0=0, ABS2=1, FAB=1?

    And when i program spc560 i should receives via CAN using pins CANH and CANL. Do i think right?

    Regards and thanks for your time

    Mateusz

    procolo
    Visitor II
    March 28, 2017
    Posted on March 28, 2017 at 08:18

    ABS0=01 ABS2=0, FAB=1

    Regard,

    Procolo

    procolo
    Visitor II
    March 29, 2017
    Posted on March 29, 2017 at 13:41

    Hi,

    Let me attach two applications.

    1) it' s the BAM emulated via SW (i've solved some bugs) . it's also able to receive program from SPCCONNECT, load in ram and jump to the application

    2) its a loader . It's able to send a bin file to the first application using CAN bus. the file to load (in this example is the serial test app for pictus complied with LOAD in RAM option ) is created using a free tool calledbin2header. it generate a file out_bin.h which should be put in source folder of the project.

    I think this is a good starting point for your bootloader application.

    Procolo

    ________________

    Attachments :

    Bootloader.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hyck&d=%2Fa%2F0X0000000bBo%2FubPzeAGOaOZ_YhalXCJmDDyAXOmoGMkAdFYJDrRr7CQ&asPdf=false
    marvin cui_O
    Visitor II
    August 4, 2017
    Posted on August 04, 2017 at 05:53

    Hi Procolo,

    I tested the Pictus bootloader demo you attached,

    with the first P50L5 board run the application ?SPC560Pxx_RLA CANsend Test Application for Discovery?,

    and the second P50L5 board run the application ?SPC560Pxx_SW_BAM?,

    and I faced a problem during testing:

    when the UDESTK debugger is connected to P50L5 on the second board which run the application of software BAM, both boards can work normally,

    the P50L5 on the second board can jump to SRAM and execute the binary code downloaded through CAN Bus successively.

    but when the UDESTK debugger is disconnected from P50L5 on the second board, the downloaded binary code can not be executed as desired,

    and at the same time, the message received from UART0 of the first board indicates that

    P50L5 on the second board has received the binary code of new application successfully through CAN Bus.

    0690X00000607r6QAA.png

    I can not find the cause of this problem, have you faced the same issue during debugging of the the attached Bootloader demo?

    version of software: UDE STK 4.8.2

                                   SPC5Studio 5.5.0

    debug tools: PLS USB/JTAG Adapter for SPC5xxx

    Thanks and best regards

    Marvin

    Mateusz Grosik
    Associate II
    March 30, 2017
    Posted on March 30, 2017 at 17:05

    Hello

    Very thanks for your help and your time.

    I program my SPC5 using this applications. But I have a question about main board (with stm32 which will send a code to SPC). I have a board STM32F103 and i add transceiver TJA1040. I made a program in C#, this program can send a *.bin file to STM32 board. I made a program for STM32 how should send something using CAN. I test in only in two STM32f103 boards with transceivers. And in my Engineering Thesis i should make a something like secondary bootloader. When i program my SPC5 (using your app) i can receive program and send it to BAM?

    In attachment i add my application for PC and STM32 (Google drive) maybe you can show it and you will under stand what i mean, becouse I was a little lost in this.

    Its like PC->STM32F103->transceivers->SPC5 board and BAM program.

    Sorry for my annoying asking but its hard for me and i cant understand that.

    https://community.st.com/external-link.jspa?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0B16SidgttMozS2JwT1p1bXEzMXc%2Fview%3Fusp%3Dsharing

    https://drive.google.com/file/d/0B16SidgttMozVUY1clVmOThxbk0/view?usp=sharing

    Best regard

    Mateusz