Copying files to ESP 32 micropython Flash directory

protein_sheikh
Posts: 2
Joined: Tue Jun 19, 2018 12:05 pm

Copying files to ESP 32 micropython Flash directory

Postby protein_sheikh » Sat Dec 01, 2018 7:01 pm

hi everyone,

i am trying to use MQTT over SSL. i have a couple of questions, would really appreciate if someone here knows how to go about solving these

1. i have a ca.crt file, which will be used to verify the identity of the server. as this https://docs.micropython.org/en/v1.8/es ... ussl.html
suggests, i should place my ca.crt file within the flash folder, so as to make it invisible. Uptill now i have been using ampy to place files, however i am not sure that will it be the same for writing files to the flash. i do get this error when i try

Code: Select all

(base) C:\Users\HP\Desktop\iot\mqtt_certificates>ampy --port COM10 put ca.crt \flash\cert
b'ets Jun  8 2016 00:22:57\r\n\r\nrst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0xee\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:2\r\nload:0x3fff0018,len:4\r\nload:0x3fff001c,len:4732\r\nload:0x40078000,len:7496\r\nload:0x40080400,len:5512\r\nentry 0x4008114c\r\n\x1b[0;32mI (244) cpu_start: Pro cpu up.\x1b[0m\r\n\x1b[0;32mI (244) cpu_start: Single core mode\x1b[0m\r\n\x1b[0;32mI (244) heap_init: Initializing. RAM available for dynamic allocation:\x1b[0m\r\n\x1b[0;32mI (248) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (254) heap_init: At 3FFC0DF8 len 0001F208 (124 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (260) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (267) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (273) heap_init: At 40091524 len 0000EADC (58 KiB): IRAM\x1b[0m\r\n\x1b[0;32mI (279) cpu_start: Pro cpu start user code\x1b[0m\r\n\x1b[0;32mI (73) cpu_start: Starting scheduler on PRO CPU.\x1b[0m\r\nOSError: [Errno 2] ENOENT\r\nMicroPython v1.9.4-701-g10bddc5c2 on 2018-12-01; ESP32 module with ESP32\r\nType "help()" for more information.\r\n>>> '
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\ampy.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\ampy\cli.py", line 228, in put
    board_files.put(remote, infile.read())
  File "c:\programdata\anaconda3\lib\site-packages\ampy\files.py", line 157, in put
    self._pyboard.enter_raw_repl()
  File "c:\programdata\anaconda3\lib\site-packages\ampy\pyboard.py", line 192, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
ampy.pyboard.PyboardError: could not enter raw repl


(base) C:\Users\HP\Desktop\iot\mqtt_certificates>ampy --port COM10 put ca.crt \flash\cert
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\ampy.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\ampy\cli.py", line 228, in put
    board_files.put(remote, infile.read())
  File "c:\programdata\anaconda3\lib\site-packages\ampy\files.py", line 158, in put
    self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
  File "c:\programdata\anaconda3\lib\site-packages\ampy\pyboard.py", line 267, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 1, in <module>\r\nOSError: [Errno 22] EINVAL\r\n')
and if i try again

Code: Select all

(base) C:\Users\HP\Desktop\iot\mqtt_certificates>ampy --port COM10 put ca.crt \flash\cert
b'ets Jun  8 2016 00:22:57\r\n\r\nrst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0xee\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:2\r\nload:0x3fff0018,len:4\r\nload:0x3fff001c,len:4732\r\nload:0x40078000,len:7496\r\nload:0x40080400,len:5512\r\nentry 0x4008114c\r\n\x1b[0;32mI (244) cpu_start: Pro cpu up.\x1b[0m\r\n\x1b[0;32mI (244) cpu_start: Single core mode\x1b[0m\r\n\x1b[0;32mI (244) heap_init: Initializing. RAM available for dynamic allocation:\x1b[0m\r\n\x1b[0;32mI (248) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (254) heap_init: At 3FFC0DF8 len 0001F208 (124 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (260) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (267) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (273) heap_init: At 40091524 len 0000EADC (58 KiB): IRAM\x1b[0m\r\n\x1b[0;32mI (279) cpu_start: Pro cpu start user code\x1b[0m\r\n\x1b[0;32mI (73) cpu_start: Starting scheduler on PRO CPU.\x1b[0m\r\nOSError: [Errno 2] ENOENT\r\nMicroPython v1.9.4-701-g10bddc5c2 on 2018-12-01; ESP32 module with ESP32\r\nType "help()" for more information.\r\n>>> '
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\ampy.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\ampy\cli.py", line 228, in put
    board_files.put(remote, infile.read())
  File "c:\programdata\anaconda3\lib\site-packages\ampy\files.py", line 157, in put
    self._pyboard.enter_raw_repl()
  File "c:\programdata\anaconda3\lib\site-packages\ampy\pyboard.py", line 192, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
ampy.pyboard.PyboardError: could not enter raw repl


(base) C:\Users\HP\Desktop\iot\mqtt_certificates>ampy --port COM10 put ca.crt \flash\cert
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\ampy.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\ampy\cli.py", line 228, in put
    board_files.put(remote, infile.read())
  File "c:\programdata\anaconda3\lib\site-packages\ampy\files.py", line 158, in put
    self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
  File "c:\programdata\anaconda3\lib\site-packages\ampy\pyboard.py", line 267, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 1, in <module>\r\nOSError: [Errno 22] EINVAL\r\n')
what should i do?

2. Also, the link suggests that the files should be .pem encoded. my .crt files are .pem encoded, but they dont have the extensions .pem, do you guys think this would be a problem?

Who is online

Users browsing this forum: daniel.kjellstrom, dzRBRglobal and 17 guests