I have this working although imperfectly. I want to share my tips for
anyone in the future that tries to do it.
First the background...
cc2430f128 and cc2431f128 both contain an 8051 cpu and 128 KB of flash
code memory. The layout of the flash ram is 4 contiguous banks with
addresses 0000...7fff, 8000...ffff, 10000...17ffff, and 18000....1ffff.
The FMAP SFR functions the same way as the PSBANK SFR in the example
trampoline crtbank.asm.
These are the flags to use on the sdcc command line. I list them as
Makefile defines. They should be added to the linking step of your build.
LDFLAGS += -Wl-bCSEG=0x000000
LDFLAGS += -Wl-bBANK1=0x018000
LDFLAGS += -Wl-bBANK2=0x028000
LDFLAGS += -Wl-bBANK3=0x038000
LDFLAGS += -Wl-r
A simple gotcha, that burned me, is an issue with the linker. It is
important for the object file containing the "main" routine to be listed
first on the linker command line. In my case, working with the Contiki
OS, the main object was linked through a library module! This led to
various routines (typically the bank switch routines) getting placed
into the HOME area before the program startup routines. An easy way to
check for this is to look in the map file generated by the linker. look
for a section labeled HOME like this:
Hexadecimal
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
HOME 0000 05C8 = 1480. bytes
(REL,CON,CODE)
Value Global
-------- --------------------------------
0C:0086 __sdcc_program_startup
0C:008B _some_routine1
0C:0097 _some_routine2
The routine __sdcc_program_startup should be first. If anything comes
before it your 8051 will not start correctly.
The next difficulty is that the bank addresses produced by the linker do
not match the actual addresses in memory. Notice that BANK1 is listed
as occurring at 0x018000 but in reality it begins at 0x8000. A post
processing step is required to modify the intel hex file that aslink
produces with the correct bank/page addressing. I was given a converter
program that handles this step. I plan to contact the source to request
permission to release this code.
Anthony*
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user