1

What I have done

I've started my first Reverse-Engineering project and have extracted the HEX from the PIC16F1938 processor of the Delonghi Dedica EC685 coffee machine. The stock firmware can be found here: Delonghi Dedica EC685 Stock Firmware

I have used MPLabX to program the simulator memory and then used the 'Output to file' to save the DisAssy output. This gives me the whole program memory and with some minor registry name fixes I 'hoped' this would be a valid Assembly file. PIC16F1938 Assembly File

Problem

When I use pic-as under the MPLab X IDE to compile this I get an error which looks to say that there isn't enough program space!? That is just wrong as the code was extracted from the device onto which we are programming.

The main error appears to be error: (1347) can't find 0x2943 words (0x2943 withtotal) for psect "code" in class "CODE" (largest unused contiguous range 0x800) which I cannot make sense of.

make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'E:/Development/Pic/Pic16f1938_test.X'
make  -f nbproject/Makefile-default.mk dist/default/production/Pic16f1938_test.X.production.hex
make[2]: Entering directory 'E:/Development/Pic/Pic16f1938_test.X'
"C:\Program Files\Microchip\xc8\v2.36\pic-as\bin\pic-as.exe" -mcpu=PIC16F1938 -c \
-o build/default/production/newpic_8b_asm_func.o \
newpic_8b_asm_func.S \
  -mdfp="C:/Program Files/Microchip/MPLABX/v6.10/packs/Microchip/PIC12-16F1xxx_DFP/1.4.213/xc8"  -msummary=+mem,+psect,+class,+hex,-file,-sha1,-sha256,-xml,-xmlfull -fmax-errors=20 -mwarn=0 -xassembler-with-cpp
"C:\Program Files\Microchip\xc8\v2.36\pic-as\bin\pic-as.exe" -mcpu=PIC16F1938 build/default/production/newpic_8b_asm_func.o \
-o dist/default/production/Pic16f1938_test.X.production.hex \
  -mdfp="C:/Program Files/Microchip/MPLABX/v6.10/packs/Microchip/PIC12-16F1xxx_DFP/1.4.213/xc8"  -msummary=+mem,+psect,+class,+hex,-file,-sha1,-sha256,-xml,-xmlfull -mcallgraph=std -Wl,-Map=dist/default/production/Pic16f1938_test.X.production.map -mdownload-hex
:0:: error: (1347) can't find 0x2943 words (0x2943 withtotal) for psect "code" in class "CODE" (largest unused contiguous range 0x800)
Non line specific message::: advisory: (1493) updated 32-bit floating-point routines might trigger "can't find space" messages appearing after updating to this release; consider using the smaller 24-bit floating-point types
:0:: warning: (528) no start record; entry point defaults to zero
(908) exit status = 1
nbproject/Makefile-default.mk:121: recipe for target 'dist/default/production/Pic16f1938_test.X.production.hex' failed
make[2]: Leaving directory 'E:/Development/Pic/Pic16f1938_test.X'
nbproject/Makefile-default.mk:85: recipe for target '.build-conf' failed
make[1]: Leaving directory 'E:/Development/Pic/Pic16f1938_test.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/Pic16f1938_test.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

Help is much appreciated as I am new to PIC assembly but I'm an experienced software engineer branching out :)

Crog
  • 1,112
  • 8
  • 16
  • I don't know anything about the pic-as' diassembler function, not even if it has one at all, but 0x800 ist the memory space of one page in the PIC. If you want to use more memory you had to do some page switching in your code. – Mike Jun 14 '23 at 04:58

1 Answers1

0

After creating a PIC disassembly of the HEX file from your git repository I put the source file (newpic_8b_asm_func.S) here.

This is the output from when it is built:

CLEAN SUCCESSFUL (total time: 14ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Public/GIT/Projects/PIC/MPLABXv5xx_pic-as_examples/Pic16f1938_test.X'
make  -f nbproject/Makefile-default.mk dist/default/production/Pic16f1938_test.X.production.hex
make[2]: Entering directory 'C:/Public/GIT/Projects/PIC/MPLABXv5xx_pic-as_examples/Pic16f1938_test.X'
"C:\PIC_dev\MPLABXC\xc8\v2.40\pic-as\bin\pic-as.exe" -mcpu=PIC16F1938 -c \
-o build/default/production/newpic_8b_asm_func.o \
newpic_8b_asm_func.S \
 -msummary=+mem,+psect,-class,-hex,-file,-sha1,-sha256,-xml,-xmlfull -fmax-errors=20 -mwarn=0 -xassembler-with-cpp -Wl,-DCODE=2,-presetVec=0h,-pisr_Vec=4h,-ppg1=1001h,-ppg2=1802h,-ppg3=2313h,-pidlocs=8000h,-peedata=F000h -Wa,-a 
"C:\PIC_dev\MPLABXC\xc8\v2.40\pic-as\bin\pic-as.exe" -mcpu=PIC16F1938 build/default/production/newpic_8b_asm_func.o \
-o dist/default/production/Pic16f1938_test.X.production.hex \
 -msummary=+mem,+psect,-class,-hex,-file,-sha1,-sha256,-xml,-xmlfull -mcallgraph=std -mdownload-hex -Wl,-DCODE=2,-presetVec=0h,-pisr_Vec=4h,-ppg1=1001h,-ppg2=1802h,-ppg3=2313h,-pidlocs=8000h,-peedata=F000h -Wa,-a 

Psect Usage Map:

 Psect    | Contents | Memory Range  | Size
----------|----------|---------------|--------------
 resetVec |          | 0000h - 0001h |    2 words  
 isr_Vec  |          | 0004h - 0FFFh |  FFC words  
 pg1      |          | 1001h - 17FFh |  7FF words  
 pg2      |          | 1802h - 1FFFh |  7FE words  
 pg3      |          | 2313h - 2942h |  630 words  
----------|----------|---------------|--------------
 eedata   |          | F000h - F0FFh |  100 bytes  
----------|----------|---------------|--------------
 config   |          | 8007h - 8008h |    2 words  
----------|----------|---------------|--------------
 idlocs   |          | 8000h - 8003h |    4 bytes  
----------|----------|---------------|--------------


Memory Summary:
    Program space        used  262Bh (  9771) of  4000h words   ( 59.6%)
    Data space           used     0h (     0) of   400h bytes   (  0.0%)
    EEPROM space         used   100h (   256) of   100h bytes   (100.0%)
    Configuration bits   used     2h (     2) of     2h words   (100.0%)
    ID Location space    used     4h (     4) of     4h bytes   (100.0%)

make[2]: Leaving directory 'C:/Public/GIT/Projects/PIC/MPLABXv5xx_pic-as_examples/Pic16f1938_test.X'
make[1]: Leaving directory 'C:/Public/GIT/Projects/PIC/MPLABXv5xx_pic-as_examples/Pic16f1938_test.X'

BUILD SUCCESSFUL (total time: 13s)
Loading code from C:/Public/GIT/Projects/PIC/MPLABXv5xx_pic-as_examples/Pic16f1938_test.X/dist/default/production/Pic16f1938_test.X.production.hex...
Program loaded with pack,PIC12-16F1xxx_DFP,1.3.90,Microchip
Loading completed
Dan1138
  • 1,150
  • 8
  • 11