How to compile an applet for sam-ba 2.18 using gcc under linux.

Microchip in-system programming solution: SAM-BA

Moderators: nferre, fab

mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

How to compile an applet for sam-ba 2.18 using gcc under linux.

Fri Jun 05, 2020 12:14 pm

I'm using sam-ba 2.18 for at91sam9260. Due to the change of the nand-flash I want to change the nandflash-applet
to support on-die-ecc. I try to use the toolchain, that I use also for my application: gcc-Version 8.3.0 (Buildroot 2019.11)

I can compile the applet and get the .bin file. But when I use it with sam-ba (on win10) it fails with timeout.

Does someone have a hint what may be wrong?
blue_z
Location: USA
Posts: 2150
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Mon Jun 08, 2020 10:35 pm

mmanzel wrote: Does someone have a hint what may be wrong?
Other than the toolchain, you have provided no details as to what you have done that led to breaking the program.

A response in a manner similar to your post:
Try a different compiler.
Look for debug messages from applet.

Or:
You could try the recommended toolchain mentioned in the SAM-BA Customization application note.
You could connect a terminal to display any text messages generated by the applet on the DBGU port .


Regards
mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Tue Jun 09, 2020 8:21 am

As first step I wanted to compile the applet without changes from my side. So I compiled it with the following output:

make BOARD=at91sam9260-ek CHIP=at91sam9260 MEMORIES=sdram -f Makefile clean all
----------------->>>
rm -f obj/*.o bin/*.bin bin/*.elf bin/*.map
arm-linux-gcc -Wall -g -O0 -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -D__ASSEMBLY__ -Dsdram -c -o obj/sdram_applet_cstartup.o ../common/applet_cstartup.S
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_main.o main.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_RawNandFlash.o ../../at91lib/memories/nandflash/RawNandFlash.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_EccNandFlash.o ../../at91lib/memories/nandflash/EccNandFlash.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_SkipBlockNandFlash.o ../../at91lib/memories/nandflash/SkipBlockNandFlash.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_NandFlashModel.o ../../at91lib/memories/nandflash/NandFlashModel.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_NandFlashModelList.o ../../at91lib/memories/nandflash/NandFlashModelList.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_NandSpareScheme.o ../../at91lib/memories/nandflash/NandSpareScheme.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_math.o ../../at91lib/utility/math.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_string.o ../../at91lib/utility/string.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_stdio.o ../../at91lib/utility/stdio.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_trace.o ../../at91lib/utility/trace.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_hamming.o ../../at91lib/utility/hamming.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_dbgu.o ../../at91lib/peripherals/dbgu/dbgu.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_pio.o ../../at91lib/peripherals/pio/pio.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_board_memories.o ../../at91lib/boards/at91sam9260-ek/board_memories.c
arm-linux-gcc -Wall -mlong-calls -ffunction-sections -g -O0 -mthumb -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -DDYN_TRACES -DTRACE_LEVEL=4 -Dsdram -c -o obj/sdram_board_lowlevel.o ../../at91lib/boards/at91sam9260-ek/board_lowlevel.c
arm-linux-gcc -g -O0 -Wl,-Map=bin/applet-nandflash-at91sam9260.map,--gc-sections -T"../../at91lib/boards/at91sam9260-ek/at91sam9260/sdram_samba.lds" -o bin/applet-nandflash-at91sam9260.elf obj/sdram_applet_cstartup.o obj/sdram_main.o obj/sdram_RawNandFlash.o obj/sdram_EccNandFlash.o obj/sdram_SkipBlockNandFlash.o obj/sdram_NandFlashModel.o obj/sdram_NandFlashModelList.o obj/sdram_NandSpareScheme.o obj/sdram_math.o obj/sdram_string.o obj/sdram_stdio.o obj/sdram_trace.o obj/sdram_hamming.o obj/sdram_dbgu.o obj/sdram_pio.o obj/sdram_board_memories.o obj/sdram_board_lowlevel.o
arm-linux-objcopy -O binary bin/applet-nandflash-at91sam9260.elf bin/applet-nandflash-at91sam9260.bin
arm-linux-size obj/sdram_applet_cstartup.o obj/sdram_main.o obj/sdram_RawNandFlash.o obj/sdram_EccNandFlash.o obj/sdram_SkipBlockNandFlash.o obj/sdram_NandFlashModel.o obj/sdram_NandFlashModelList.o obj/sdram_NandSpareScheme.o obj/sdram_math.o obj/sdram_string.o obj/sdram_stdio.o obj/sdram_trace.o obj/sdram_hamming.o obj/sdram_dbgu.o obj/sdram_pio.o obj/sdram_board_memories.o obj/sdram_board_lowlevel.o bin/applet-nandflash-at91sam9260.elf
text data bss dec hex filename
240 0 0 240 f0 obj/sdram_applet_cstartup.o
4484 16 72 4572 11dc obj/sdram_main.o
5397 0 0 5397 1515 obj/sdram_RawNandFlash.o
1499 0 1 1500 5dc obj/sdram_EccNandFlash.o
2347 0 0 2347 92b obj/sdram_SkipBlockNandFlash.o
1530 0 0 1530 5fa obj/sdram_NandFlashModel.o
708 0 0 708 2c4 obj/sdram_NandFlashModelList.o
1119 0 0 1119 45f obj/sdram_NandSpareScheme.o
110 0 0 110 6e obj/sdram_math.o
608 0 0 608 260 obj/sdram_string.o
2008 20 0 2028 7ec obj/sdram_stdio.o
1472 4 0 1476 5c4 obj/sdram_trace.o
1935 0 0 1935 78f obj/sdram_hamming.o
208 0 0 208 d0 obj/sdram_dbgu.o
778 0 0 778 30a obj/sdram_pio.o
1296 0 0 1296 510 obj/sdram_board_memories.o
274 0 0 274 112 obj/sdram_board_lowlevel.o
23008 232 84 23324 5b1c bin/applet-nandflash-at91sam9260.elf


I replaced the "applet-nandflash-at91sam9260.bin" in "...\sam-ba_2.18\tcl_lib\at91sam9260-ek" by the output.
(The size of the applet is quite the same.)
The problem with the debug messages is, that it does not send any message; there is RomBOOT > and nothing more.
I know the output of the original applet and had expected something similar.
It looks like something goes wrong before the start of the applet.

The toolchain works fine for bootstrap, u-boot and linux, so I hope it should do also for the applet.
mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Tue Jun 09, 2020 9:11 am

The given Makefile does not use -static in the linker command.
Could that be a problem?
mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Tue Jun 09, 2020 12:03 pm

If I add -static to the LDFLAGS I have to define two empty funtions: __exidx_start and __exidx_end
and the file becomes a size of 400kB (instead of 16kB).
But I still get a timeout and no output on DBGU port.
mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Tue Jun 09, 2020 1:52 pm

I tried also compiling with: gcc version 4.2.0 (Sourcery G++ 4.2-28).

This comes up with the linker error:

/opt/timesys/toolchains/lib/gcc/arm-timesys-linux-gnueabi/4.2.0/../../../../arm-timesys-linux-gnueabi/bin/ld: error: no memory region specified for loadable section `.note.ABI-tag'
collect2: ld returned 1 exit status
Makefile:226: die Regel für Ziel „sdram“ scheiterte
make: *** [sdram] Fehler 1
mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Wed Jun 10, 2020 3:40 pm

Dear blue_z,

I think you should have the same problem: the BOM of the sam9260-ek contains a K9F2G08U0A-PCB0T now
and the ECC of sam-ba is too weak for this nand. How do you flash the images?

Thank you
blue_z
Location: USA
Posts: 2150
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Thu Jun 11, 2020 3:41 am

mmanzel wrote: As first step I wanted to compile the applet without changes from my side. So I compiled it with the following output:

make BOARD=at91sam9260-ek CHIP=at91sam9260 MEMORIES=sdram -f Makefile clean all
----------------->>>
rm -f obj/*.o bin/*.bin bin/*.elf bin/*.map
arm-linux-gcc -Wall -g -O0 -I../../at91lib/boards/at91sam9260-ek -I../../at91lib/peripherals -I../../at91lib/memories -I../../at91lib/drivers -I../../at91lib -Dat91sam9260 -D__ASSEMBLY__ -Dsdram -c -o obj/sdram_applet_cstartup.o ../common/applet_cstartup.S
...
You ask for help "to compile an applet for sam-ba 2.18" but provide no salient details of what you have done for the possible benefit of others to follow.

a) Mentioning the directory you are working in is relevant.
b) Apparently there's a workaround for old toolchains that now needs to be edited out, and you have already (silently) performed that, since your "output" does not fail with the multiple definition of `_impure_ptr' error.
c) Your build looks perfectly (but suspiciously) clean, whereas I get an extraneous "control reaches end of non-void function" warning for RawNandFlash.c.
d) The documentation and makefile specifies a toolchain with the prefix "arm-none-eabi-", but apparently you have (silently) modified the makefile.

A toolchain with either prefix is supposed to be valid for baremetal/standalone programs, but if there are issues (as you are having) then a toolchain specifically intended for baremetal (i.e. no library) is the obvious preference over a toolchain intended for glibc.

mmanzel wrote: I think you should have the same problem: ...
How do you flash the images?
You are mistaken.
i do not have or use an AT91SAM9260-EK.

Regards
mmanzel
Posts: 17
Joined: Mon May 25, 2020 10:42 am

Re: How to compile an applet for sam-ba 2.18 using gcc under linux.

Thu Jun 11, 2020 11:12 am

Dear blue_z,

a) sam-ba_2.18/applets/legacy/sam-ba_applets/nandflash
b) I commented it out to get it compiled (as proposed).
c) return 0;

d) This is really the hint! Thank you.
Now I use gcc-arm-none-eabi-9-2020-q2-update and it starts as expected.

e) You did not mention the warning:
main.c:685:17: warning: 'memset' forming offset [5, 48] is out of the bounds [0, 4] of object 'end' with type 'unsigned int' [-Warray-bounds]
685 | memset((unsigned char *)bufferAddr, 0xFF, NandCommon_MAXSPAREECCBYTES);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:197:21: note: 'end' declared here
197 | extern unsigned int end;

It seams to work, but should "end" be declared as array to make it correct?

f) But there is the problem, that the current sam9260-ek can not work with the proposed sam-ba.
g) possible benefit: If I should get the on-die-ecc working I can add the changes here.

Thank you

Return to “SAM-BA”

Who is online

Users browsing this forum: No registered users and 1 guest