Using assembler files leads to build error
maxgerhardt opened this issue · 2 comments
Please first note that due to issue platformio/platformio-core#3917, only on Linux and Mac platforms, the sdas8051
assembler is actually invoked, and not SDCC.
However, even under e.g. Linux, when using the following platformio.ini
[env:stc15f204ea]
platform = intel_mcs51
board = stc15f204ea
and src/blink.s
adapted from here)
.module blink
.area HOME (CODE)
.area XSEG (DATA)
.area PSEG (DATA)
.area INTV (ABS)
.org 0x0000
_int_reset:
ljmp main
.area CSEG (ABS, CODE)
.org 0x0090
main:
cpl P3.2
acall delay
cpl P3.3
acall delay
cpl P3.4
acall delay
cpl P3.5
acall delay
nop
nop
nop
nop
sjmp main
delay:
mov r4, #0x00
mov r3, #0x00
wait:
djnz r4, wait
djnz r3, wait
ret
will lead to a build failure
Processing stc15f204ea (platform: intel_mcs51; board: stc15f204ea)
------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/intel_mcs51/stc15f204ea.html
PLATFORM: Intel MCS-51 (8051) (1.2.3) > Generic STC15F204EA
HARDWARE: STC15F204EA 11MHz, 256B RAM, 4KB Flash
PACKAGES:
- tool-stcgal 1.104.0 (1.4)
- toolchain-sdcc 1.30804.10766 (3.8.4)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
sdas8051 -o .pio/build/stc15f204ea/src/blinky.rel src/blinky.s
sdcc -o .pio/build/stc15f204ea/firmware.hex -mmcs51 --iram-size 256 --xram-size 0 --code-size 4096 --out-fmt-ihx .pio/build/stc15f204ea/src/blinky.rel -L.pio/build/stc15f204ea
?ASlink-Error-<cannot open> : ".pio/build/stc15f204ea/src/blinky.lst"
*** [.pio/build/stc15f204ea/firmware.hex] Error 1
============================================== [FAILED] Took 0.57 seconds ==============================================
Because the assembler flags are lackign the options to create .lst
and .sym
files. If I add
extra_scripts = pre:fix_asm.py
to the platformio.ini
with script content
Import("env")
env.Append(ASFLAGS=["-l", "-s"])
it builds
Building in release mode
sdas8051 -l -s -o .pio/build/stc15f204ea/src/blinky.rel src/blinky.s
sdcc -o .pio/build/stc15f204ea/firmware.hex -mmcs51 --iram-size 256 --xram-size 0 --code-size 4096 --out-fmt-ihx .pio/build/stc15f204ea/src/blinky.rel -L.pio/build/stc15f204ea
MethodWrapper(["checkprogsize"], [".pio/build/stc15f204ea/firmware.hex"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
Flash: [ ] 0.8% (used 31 bytes from 4096 bytes)
Internal RAM layout:
0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|A|A|A| | | | | | | | | | | | | |
0x10:| | | | | | | | | | | | | | | | |
0x20:| | | | | | | | | | | | | | | | |
0x30:| | | | | | | | | | | | | | | | |
0x40:| | | | | | | | | | | | | | | | |
0x50:| | | | | | | | | | | | | | | | |
0x60:| | | | | | | | | | | | | | | | |
0x70:| | | | | | | | | | | | | | | | |
0x80:| | | | | | | | | | | | | | | | |
0x90:| | | | | | | | | | | | | | | | |
0xa0:| | | | | | | | | | | | | | | | |
0xb0:| | | | | | | | | | | | | | | | |
0xc0:| | | | | | | | | | | | | | | | |
0xd0:| | | | | | | | | | | | | | | | |
0xe0:| | | | | | | | | | | | | | | | |
0xf0:| | | | | | | | | | | | | | | | |
0-3:Reg Banks, T:Bit regs, a-z:Data, B:Bits, Q:Overlay, I:iData, S:Stack, A:Absolute
No clue at where the stack begins and ends!
The largest spare internal RAM space starts at 0x3 with 253 bytes available.
Other memory:
Name Start End Size Max
---------------- -------- -------- -------- --------
PAGED EXT. RAM 0 0
EXTERNAL RAM 0 0
ROM/EPROM/FLASH 0x0000 0x001e 31 4096
============================================= [SUCCESS] Took 0.62 seconds =============================================
but no idea whether it runs.
In any way, by default this doesn't work, hence the issue here.
Hi
I have tested the code on other environment and increased the delay as the delay in the code is not enough to make the blinking visible , the delay routine became :
delay:
mov r4, #0x00
mov r3, #0x00
mov r2, #0x00
wait:
djnz r4, wait
djnz r3, wait
djnz r2, wait
ret
Then it works successfully 👍
I suggest to add the assembler arguments :
env.Append(ASFLAGS=["-l", "-s"])
to the main.py of the platform in the coming updates.
Fixed in d0a8315
P.S: The minimum support version of PlatformIO Core is 5.3