boochow / micropython-raspberrypi

bare metal Raspberry Pi Zero / Zero W port of MicroPython
MIT License
215 stars 24 forks source link

Troubleshooting. SD Card not supported. #29

Closed astrelsky closed 4 years ago

astrelsky commented 4 years ago

Is this supposed to be functional? I've compiled the current branch and installed it as described in the readme. I have also tried the release distribution and I get the same result. Running on raspberry pi zero V1.3. I've tried raspbian and that works just fine so I know the board is at least functional. I had also tried the release about a year ago, uncommented the lines in main.py and was always presented with a bunch of random colors on the screen.

Here is a screenshot of the layout of my sd card. root

This is the contents of main.py. Everything else remains unchanged.

from machine import Pin

led = Pin(47, Pin.OUT)   # create output pin on GPIO47 (on-board LED)
led(0)                   # set pin to on/low
while True:
    pass

I would expect the led to turn on and remain on. However, it blinks a couple times, turns off pauses and then quickly blinks and stays off. This appears to be the behavior when it fails to boot the .img file.

boochow commented 4 years ago

Hi Astrelsky thank you for testing this. Current main branch works for me ( I usually use zero w v 1.1).

Here is a screenshot of the layout of my sd card.

it seems good. Does config.txt has the line kernel=firmware.img?

it blinks a couple times, turns off pauses and then quickly blinks and stays off. This appears to be the behavior when it fails to boot the .img file.

Yeah I agree with you. To test whether your environment executes firmware.img or not, could you build an bare-metal Raspberry Pi program and replace firmware.img with it?

An example of bare-matal program is here:

https://github.com/boochow/bare_matal_rpi_zero/tree/master/led_blynk

This is a simple code which blinks LED eternaly.

astrelsky commented 4 years ago

it seems good. Does config.txt has the line kernel=firmware.img?

Yes.

To test whether your environment executes firmware.img or not, could you build an bare-metal Raspberry Pi program and replace firmware.img with it?

An example of bare-matal program is here:

https://github.com/boochow/bare_matal_rpi_zero/tree/master/led_blynk

This is a simple code which blinks LED eternaly.

Compiling and executing the provided sample works without a problem. I changed the main.py above to now set GPIO47 to LOW but it still doesn't appear to work. Is there a way to know if micropython is able to access main.py?

boochow commented 4 years ago

Is there a way to know if micropython is able to access main.py?

While booting you’ll see a message “mounting SD card...done”( or “failed”) on UART. If you do not have UART interface module, I strongly recommend to get one.

There may be compatibility problems between SD cards and the card reader driver, so using an other vendor’s SD card could solve the problem.

astrelsky commented 4 years ago

Is there a way to know if micropython is able to access main.py?

While booting you’ll see a message “mounting SD card...done”( or “failed”) on UART. If you do not have UART interface module, I strongly recommend to get one.

There may be compatibility problems between SD cards and the card reader driver, so using an other vendor’s SD card could solve the problem.

I see. I'll hook up the uart connections to an arduino to monitor the status. If that is the case I'll close this.

astrelsky commented 4 years ago

So I get nothing over uart. However I am receiving information when I have NOOBS on the sd card and I get output when using the bare-metal uart example.

I had to set VERBOSE to 1 in sd.c. I'm debugging it now.

boochow commented 4 years ago

If you connected UART with 9600 bps, please re-configure it to 115200, 8bit for MicroPython.

astrelsky commented 4 years ago

If you connected UART with 9600 bps, please re-configure it to 115200, 8bit for MicroPython.

Here is the output I received. It does indeed start micropython so it may be related to the sd card drivers. I can look into updating them if necessary.

output ``` mounting SD card...EMMC: GPIO set up EMMC: reset OK sd_clk divisor 00000068, shift 00000006 EMMC: Sending command 00000000 arg 00000000 EMMC: Sending command 08020000 arg 000001AA EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned VOLTAGE CCS 40F98000 EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned COMPLETE VOLTAGE CCS C1F98000 EMMC: Sending command 02010000 arg 00000000 EMMC: Sending command 03020000 arg 00000000 EMMC: CMD_SEND_REL_ADDR returned AAAA0000 sd_clk divisor 00000004, shift 00000001 EMMC: Sending command 07030000 arg AAAA0000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 33220010 arg 00000000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 06020000 arg AAAA0002 EMMC: supports SET_BLKCNT CCS sd_readblock lba 00000000 num 00000001 EMMC: Sending command 11220010 arg 00000000 sd_readblock lba 00000800 num 00000001 EMMC: Sending command 11220010 arg 00000800 sd_readblock lba 00000801 num 00000001 EMMC: Sending command 11220010 arg 00000801 EMMC: GPIO set up EMMC: reset OK sd_clk divisor 00000068, shift 00000006 EMMC: Sending command 00000000 arg 00000000 EMMC: Sending command 08020000 arg 000001AA EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned VOLTAGE CCS 41F98000 EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned COMPLETE VOLTAGE CCS C1F98000 EMMC: Sending command 02010000 arg 00000000 EMMC: Sending command 03020000 arg 00000000 EMMC: CMD_SEND_REL_ADDR returned AAAA0000 sd_clk divisor 00000004, shift 00000001 EMMC: Sending command 07030000 arg AAAA0000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 33220010 arg 00000000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 06020000 arg AAAA0002 EMMC: supports SET_BLKCNT CCS sd_readblock lba 00000000 num 00000001 EMMC: Sending command 11220010 arg 00000000 EMMC: GPIO set up EMMC: reset OK sd_clk divisor 00000068, shift 00000006 EMMC: Sending command 00000000 arg 00000000 EMMC: Sending command 08020000 arg 000001AA EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned VOLTAGE CCS 41F98000 EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned COMPLETE VOLTAGE CCS C1F98000 EMMC: Sending command 02010000 arg 00000000 EMMC: Sending command 03020000 arg 00000000 EMMC: CMD_SEND_REL_ADDR returned AAAA0000 sd_clk divisor 00000004, shift 00000001 EMMC: Sending command 07030000 arg AAAA0000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 33220010 arg 00000000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 06020000 arg AAAA0002 EMMC: supports SET_BLKCNT CCS sd_readblock lba 00000000 num 00000001 EMMC: Sending command 11220010 arg 00000000 EMMC: GPIO set up EMMC: reset OK sd_clk divisor 00000068, shift 00000006 EMMC: Sending command 00000000 arg 00000000 EMMC: Sending command 08020000 arg 000001AA EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned VOLTAGE CCS 41F98000 EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned COMPLETE VOLTAGE CCS C1F98000 EMMC: Sending command 02010000 arg 00000000 EMMC: Sending command 03020000 arg 00000000 EMMC: CMD_SEND_REL_ADDR returned AAAA0000 sd_clk divisor 00000004, shift 00000001 EMMC: Sending command 07030000 arg AAAA0000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 33220010 arg 00000000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 06020000 arg AAAA0002 EMMC: supports SET_BLKCNT CCS sd_readblock lba 00000000 num 00000001 EMMC: Sending command 11220010 arg 00000000 done sd_readblock lba 00008800 num 00000001 EMMC: Sending command 11220010 arg 00008800 sd_readblock lba 00008920 num 00000001 EMMC: Sending command 11220010 arg 00008920 sd_readblock lba 00008800 num 00000001 EMMC: Sending command 11220010 arg 00008800 sd_readblock lba 00008BC0 num 00000001 EMMC: Sending command 11220010 arg 00008BC0 sd_readblock lba 00008BC1 num 00000001 EMMC: Sending command 11220010 arg 00008BC1 sd_readblock lba 00008800 num 00000001 EMMC: Sending command 11220010 arg 00008800 sd_readblock lba 000088A0 num 00000001 EMMC: Sending command 11220010 arg 000088A0 sd_readblock lba 00008800 num 00000001 EMMC: Sending command 11220010 arg 00008800 sd_readblock lba 000088A0 num 00000001 EMMC: Sending command 11220010 arg 000088A0 sd_readblock lba 00008800 num 00000001 EMMC: Sending command 11220010 arg 00008800 EMMC: GPIO set up EMMC: reset OK sd_clk divisor 00000068, shift 00000006 EMMC: Sending command 00000000 arg 00000000 EMMC: Sending command 08020000 arg 000001AA EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned VOLTAGE CCS 41F98000 EMMC: Sending command 37000000 arg 00000000 EMMC: Sending command 29020000 arg 51FF8000 EMMC: CMD_SEND_OP_COND returned COMPLETE VOLTAGE CCS C1F98000 EMMC: Sending command 02010000 arg 00000000 EMMC: Sending command 03020000 arg 00000000 EMMC: CMD_SEND_REL_ADDR returned AAAA0000 sd_clk divisor 00000004, shift 00000001 EMMC: Sending command 07030000 arg AAAA0000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 33220010 arg 00000000 EMMC: Sending command 37020000 arg AAAA0000 EMMC: Sending command 06020000 arg AAAA0002 EMMC: supports SET_BLKCNT CCS sd_readblock lba 00002000 num 00000001 EMMC: Sending command 11220010 arg 00002000 0000:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0010:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0020:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0030:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0040:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0050:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0060:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0070:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0080:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0090:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00a0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00b0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00c0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00d0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00e0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00f0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0100:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0110:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0120:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0130:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0140:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0150:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0160:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0170:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0180:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0190:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01a0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01b0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01c0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01d0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01e0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01f0:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ MicroPython 2fdb2db-dirty on 2020-01-28; Raspberry Pi with ARM1176JZF-S Type "help()" for more information. >>> TypeError: argument num/types mismatch TypeError: argument num/types mismatch TypeError: argument num/types mismatch TypeError: argument num/types mismatch ```

TypeError: argument num/types mismatch continues to loop infinitely.

@boochow it appears to be fully functional as I got a 'hello world' script working. The TypeError appears to be coming from the example main.py script in the last release (It is because the sd card cannot be mounted). Thank you for your assistance!

boochow commented 4 years ago

@astrelsky I am very happy to hear that! I appreciate your information.

astrelsky commented 4 years ago

@astrelsky I am very happy to hear that! I appreciate your information.

No problem. Just to make everything 100% clear. Micropython itself works, the sd card driver doesn't. I'll work around that or pre compile it though.