Although having multiple issues in one thread will make for a messy thread, here’s the next issue:
Title: Setup / CWHUSKY / SAM4S - firmware too large?
Continuing the discussion from Setup / Husky – multiple errors in jupyter notebooks, which lists the config:
Walking through 1 - Connecting to Hardware.ipynb, in section Building and Uploading Firmware:
The compilation worked fine. Relevant part:
LINKING:
-en simpleserial-base-CWHUSKY.elf ...
Memory region Used Size Region Size %age Used
rom: 3424 B 128 KB 2.61%
ram: 4648 B 64 KB 7.09%
...
Size after:
text data bss dec hex filename
3424 4 4644 8072 1f88 simpleserial-base-CWHUSKY.elf
However, the following attempt to upload the firmware fails:
cw.program_target(scope, cw.programmers.SAM4SProgrammer, "../firmware/mcu/simpleserial-base/simpleserial-base-CWHUSKY.elf")
With the error:
OSError: File too big (need 887 pages, have 256)
Full Compilation Log
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[8], line 4
1 #cw.program_target(scope, cw.programmers.XMEGAProgrammer, "path/to/firmware.hex")
2 #cw.program_target(scope, cw.programmers.STM32FProgrammer, "path/to/firmware.hex")
3 #cw.program_target(scope, cw.programmers.AVRProgrammer, "path/to/firmware.hex")
----> 4 cw.program_target(scope, cw.programmers.SAM4SProgrammer, "../firmware/mcu/simpleserial-base/simpleserial-base-CWHUSKY.elf")
File ~/src/chipwhisperer/software/chipwhisperer/__init__.py:183, in program_target(scope, prog_type, fw_path, **kwargs)
181 prog.find()
182 prog.erase()
--> 183 prog.program(fw_path, memtype="flash", verify=True)
184 prog.close()
185 except:
File ~/src/chipwhisperer/software/chipwhisperer/capture/api/programmers.py:129, in save_and_restore_pins.<locals>.func_wrapper(self, *args, **kwargs)
126 target_logger.debug('Changing {} pin configuration'.format(pin_setup))
128 try:
--> 129 val = func(self, *args, **kwargs)
130 finally:
131 target_logger.debug('Restoring {} pin configuration'.format(pin_setup))
File ~/src/chipwhisperer/software/chipwhisperer/capture/api/programmers.py:207, in SAM4SProgrammer.program(self, filename, memtype, verify)
204 fw_data = open(filename, "rb").read()
206 target_logger.info("Programming...")
--> 207 prog.write(fw_data)
208 target_logger.info("Verifying...")
209 if prog.verify(fw_data):
210 # prog.reset()
File ~/src/chipwhisperer/software/chipwhisperer/hardware/naeusb/bootloader_sam3u.py:446, in Samba.write(self, bindata, doprint)
444 totalpages = (len(bindata) + page_size - 1) / page_size
445 if totalpages > page_max:
--> 446 raise IOError("File too big (need %d pages, have %d)" % (totalpages, page_max))
448 bytesleft = len(bindata)
450 i = 0
OSError: File too big (need 887 pages, have 256)
It seems REALLY unlikely that a firmware whose .text section is only 0x1F88 bytes would require 0x337 pages … that would make the page size ~24 bytes per page(!).
Is this expected to fail?
Is there a workaround?
Better yet, is there a proper fix available? 
Thank you!