-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MicroPython: Filesystem will not mount #88
Comments
The file system is not initialized by the emulator. If you want to have a file system, you'd need to create it yourself and make it available in a specific location in the simulated flash memory. For MicroPython on the Raspberry Pi Pico, that'd be littlefs at flash offset 0xa0000, with a block size of 4k and 352 blocks. What project are you working on? |
OK, So I can use littlefs to create a filesystem starting at 0xa0000 for 352 blocks at 4kB per block. I have been able to successfully write files that MicroPython can see using the code you provided before: #81 (comment); however, I still get Here are the steps I use that allows MicroPython see files but still fails on MP file creation:
Here's the code for step 2:
|
I thought your name was familiar :) For proper writing to flash, you'd need to implement the SSI peripheral (see section 4.10 of the datasheet) A workaround would be to patch the The details of that function are available in section 2.8.2.1.3. You could also compile your own version of the bootrom, and replace this function with your own implementation. |
How did the wokwi simulator do it? I'm guessing the bootrom workaround? I noticed that files can be created without the error. |
Yes, the bootrom workaround. I was too lazy to implement the SSI peripheral (thought that's obviously the better solution) |
Does that edited bootrom code live anywhere? Still not clear exactly what's wrong with |
Don't worry about many asking questions. It's not an easy stuff, took me a while to figure it out too. Nothing is wrong with When hitting that breakpoint, you'll find the parameters of the function in the r0, r1, r2 registers. They'll tell you where to write the data in the flash ( At that point, all you have to do is to read the data from the RAM, write it to the flash, and return to the caller (by copying the value of the LR register to the PC register). |
Looking at the bootrom's code, it seems like implementing the relevant part of the SSI peripheral should be too hard as well. It might be even easier than my workaround. If you want to try that and need some pointers, please let me know. |
Clever. I replaced How do I figure out what opcode to look for? It should be the last one executed in here, right? |
This one: Line 965 in f0eabd0
Note that it calls |
Is this about what you meant?
File creation works through MicroPython now but only if I don't set the stop flag. Does this have to do with how I copy LR to PC? Should it be done in the bootrom? I'm not sure it matters if I copy LR to PC if I just don't stop the emulator, but I guess this means I get rid of the potential to use breakpoints in some cases? |
That sounds right. You can probably rewrite the last line before the I wouldn't worry too much about the potential use of breakpoint. You still have 254 available "codes" for breakpoints. If I remember correctly, GDB always uses 0, so breakpoints in GDB still work. |
Do you know if the littlefs.wasm package you made exposes directory functions? For example,
Which I assume relates to this in littlefs Does that mean I can do something similar for making directories based on this? I assume the way you compiled littlefs with emscripten needs to include some export flag for the function? |
I made the source code public, so you can have a look: https://github.com/wokwi/littlefs-wasm. Most of the API is exported, and you can play around with test.js to experiment with different functions. One day I may even get around to adding a REAMDE file there :) |
Thanks, I'll take a look! |
rp2040js: 0.14.6
MicroPython: 1.17
OS: Windows 10
Steps to reproduce:
git clone https://github.com/wokwi/rp2040js.git
cd rp2040js
npm install
npm run start:micropython
f = open('test.txt', 'w')
Corresponds to filesystem not mounted: https://forum.micropython.org/viewtopic.php?t=1855#p10444
The text was updated successfully, but these errors were encountered: