espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.75k stars 740 forks source link

save() reports -4 bytes available on nRF51 #910

Closed ddm closed 7 years ago

ddm commented 7 years ago

Tested with the following nRF51 variants (QFN48):

info = {
 'name' : "noho-plug",
 'link' :  [ "https://www.noho.care" ],
 'default_console' : "EV_SERIAL1",
 'default_console_tx' : "D29",
 'default_console_rx' : "D30",
 'default_console_baudrate' : "115200",
 'variables' : 310,
 'binary_name' : 'noho-plug.bin',
 'build' : {
  'defines' : [
     'USE_BLUETOOTH'
   ]
 }
};

chip = {
  'part' : "NRF51822", # QFAA
  'family' : "NRF51",
  'package' : "QFN48",
  'ram' : 16,
  'flash' : 256,
  'speed' : 16,
  'usart' : 1,
  'spi' : 1,
  'i2c' : 0,
  'adc' : 1,
  'dac' : 0,
  'saved_code' : {
    'address' : ((256 - 3) * 1024),
    'page_size' : 1024,
    'pages' : 0,
    'flash_available' : (256 - 108 - 3)
  }
};

To reproduce using the PCA10028 development kit:

  1. git clone https://github.com/espruino/Espruino.git && cd Espruino
  2. git co 1317aa0
  3. NRF51822DK=1 RELEASE=1 make
  4. Flash espruino_1v86.1614_nrf51822.hex to PCA10028 DK
  5. UART @ 9600 bauds/8 bits/no parity or nRF UART 2.0 (Android)
  6. save()ERROR: Too big to save to flash (xxx vs -4 bytes) regardless of the code.
universal commented 7 years ago

I think i had a similar issue playing with a waveshare clone, and still have other issues. I think i fixed the byte issue with a changed config, might have just been pages in the chip section which i changed. I hope i don't forget it tomorrow, i only have the code at my work machine since it is still toying around :-)

ddm commented 7 years ago

Funny you mention that: I noticed it works on my custom board (but not the PCA10028) when I just add the -g3 compiler flag and drop RELEASE=1. No amount of work on the saved_code board config values seems to do any good though.

gfwilliams commented 7 years ago

On micro:bit this works I think. Change pages:0 to pages:3 in your file - seems to be a bug in the nRF51DK board file

ddm commented 7 years ago

@gfwilliams Thank you for the fix Gordon! I just realised that changing gcc flags had nothing to do with me getting it to work: I had set pages:3 on my custom board too... I guess the nRFTag board should be updated since it uses the same nRF51822-QFAA variant as the micro:bit and my custom board.