Do you by any chance have the EMMC memory onboard?
#!/usr/bin/env python3
import depthai as dai
# Create pipeline
pipeline = dai.Pipeline()
cfg = dai.BoardConfig()
cfg.emmc = True
cfg.logPath = '/media/mmcsd-0-0/depthai_log_file.txt'
config = dai.Device.Config()
config.board = cfg
pipeline.setBoardConfig(cfg)
# Define source and output
camRgb = pipeline.create(dai.node.ColorCamera)
jpegEncoder = pipeline.create(dai.node.VideoEncoder)
scriptSave = pipeline.create(dai.node.Script)
scriptServer = pipeline.create(dai.node.Script)
# Properties
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_4_K)
jpegEncoder.setDefaultProfilePreset(1, dai.VideoEncoderProperties.Profile.MJPEG)
# Note: all scripts accessing the media storage must run on LEON_CSS
scriptSave.setProcessor(dai.ProcessorType.LEON_CSS)
scriptSave.setScript("""
import os
index = 1000
import time
while True:
# Find an unused file name first
while True:
path = '/media/mmcsd-0-0/' + str(index) + '.jpg'
if not os.path.exists(path):
break
index += 1
frame = node.io['jpeg'].get()
node.warn(f'Saving to SDcard: {path}')
with open(path, 'wb') as f:
f.write(frame.getData())
index += 1
time.sleep(3)
""")
scriptServer.setProcessor(dai.ProcessorType.LEON_CSS)
scriptServer.setScript("""
import http.server
import socketserver
import socket
import fcntl
import struct
import os
import time
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
-1071617759, # SIOCGIFADDR
struct.pack('256s', ifname[:15].encode())
)[20:24])
# Note: `chdir` here will prevent unmount, this should be improved!
time.sleep(1)
os.chdir('/')
PORT = 80
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
ip = get_ip_address('re0')
node.warn(f'===== HTTP file server accessible at: http://{ip}')
httpd.serve_forever()
""")
# Linking
camRgb.video.link(jpegEncoder.input)
jpegEncoder.bitstream.link(scriptSave.inputs['jpeg'])
scriptSave.inputs['jpeg'].setBlocking(False)
(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
bootloader = dai.DeviceBootloader(bl)
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
(r, errmsg) = bootloader.flash(progress, pipeline, memory=dai.DeviceBootloader.Memory.EMMC)
if r: print("Flash OK")
else: print("Flash ERROR:", errmsg)
Perhaps you can try logging to the emmc storage like the above example to see what might be the issue.
Thanks,
Jaka