PlatformIO Community

Any known tools to port µVision .s assembly files to GNU .S assembly files?

I’ve got an example project, that contains some .s assembly files, that seem to be supported on Windows on Keil’s MDK. I’d like to use platformIO on macOS and obviously the GNU compiler toolchain, but that toolchain seems not to support those .s files properly.

So I’d like to ask, whether there are any known tools to convert those .s assembly files to .S GNU assembly files.

Best regards.

Why port? I’m sure you’re talking about the LPC176X startfile. Just take the LXP provided one for the GCC toolchain: https://github.com/scottellis/lpc17xx.cmsis.driver.library/tree/master/Core/CM3/DeviceSupport/NXP/LPC17xx/startup (or also here: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/startup_LPC17xx.S)

Getting compiler errors there:

lib/LPC17xx/startup_LPC17xx.S:126: Error: non-constant expression in ".if" statement

See https://github.com/scottellis/lpc17xx.cmsis.driver.library/blob/bcd89be52800e8db7b10421abcc6d527f6b2f8db/makesection/makerule/example/makefile.ex#L160

Must add -D__RAM_MODE__=0 to the build_flags of the platformio.ini

I’m getting the same error.

Try

-Wa,--defsym RAM_MODE=0 

instead in the build_flags. If that doesn’t work just replace RAM_MODE with a constant 0 in the startup file…

Replacing RAM_MODE with a 0 in the assembly file solved the problem, but I’m still getting that checksum mismatch error.

xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 10 kHz
Info : SWD DPIDR 0x2ba01477
Info : lpc17xx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
Info : High speed (adapter_khz 12500) may be limited by adapter firmware.
** Programming Started **
Warn : Verification will fail since checksum in image (0x02b6aa63) to be written to flash is different from calculated vector checksum (0x02b6aa66).
Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
** Programming Finished **
** Verify Started **
Error: checksum mismatch - attempting binary compare
embedded:startup.tcl:449: Error: ** Verify Failed **
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 494
at file "embedded:startup.tcl", line 449
*** [upload] Error 1

Can you upload the firmware.bin file here?

The forum doesn’t support neither bin, nor zip files.
Changing the extension to .jpeg doesn’t work either.
none of the image files work, as the forum checks, what dimension they have and tells me that the file might be corrupted.

Can you use a google drive or push it in a git repo?

http://www.mediafire.com/file/h82uceo734rhio8/firmware.bin/file

Update: The python script (original source) computes the checksum wrong, the C program which the python script is based on computes it correctly.

C:\Users\Maxi\Desktop>python lpcrc.py firmware.bin
Firmware path: firmware.bin
Wrote checksum 0x2b6aa63 into binary.

C:\Users\Maxi\Desktop>lpcrc.exe firmware.bin
succesfully updated crc to: 02b6aa66

So I’m gonna go search for the porting error the person made in the python script.

Yeah they don’t do 32-bit arithmetic in the case of an overflow correctly. Go to your extra_script.py and find the line

result = (result + value) % 0xFFFFFFFF

and replace it with

result = (result + value) & 0xFFFFFFFF

Also reported at https://github.com/basilfx/lpc_checksum/issues/2.

1 Like

It builds and uploads properly, even tho the upload succeeds, I’m still a little bit concerned about this red error message:

==== Post building BIN file ====
Firmware path: .pio/build/lpc1768/firmware.bin
Wrote checksum 0x2b6aa66 into binary.
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, custom, jlink, mbed
CURRENT: upload_protocol = custom
Uploading .pio/build/lpc1768/firmware.bin
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 10 kHz
Info : SWD DPIDR 0x2ba01477
Info : lpc17xx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
Info : High speed (adapter_khz 12500) may be limited by adapter firmware.
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : SWD DPIDR 0x2ba01477
Error: lpc17xx.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x60000003 pc: 0x4b07b508 msp: 0xbf00b5d8
Polling target lpc17xx.cpu failed, trying to reexamine
Info : lpc17xx.cpu: hardware has 6 breakpoints, 4 watchpoints
shutdown command invoked

Horay for bugfixes

The chip got another exception while already executing an exception handler, suggesting something crashed really hard, supposedly the startup file is not yet working as intented. Is the current state pushed to your repo for reproduction?

It’s on the raw_blinky branch.