Microbit doesn't run flashed program when seated in Max:bot - robot

My son bought a Max:bot DIY Programmable Robot Kit, which uses a BBC Microbit.
You can see above where the Microbit slots in.
What works ...
To set the scene of our problem, we'll set aside the Max:bot for a moment and just consider the Microbit in isolation ...
Using Microsoft MakeCode, we can code a simple program to drive the LEDs on the Microbit. With the Microbit unseated from the Max:bot, and connected to a Mac over USB, we can successfully flash the Microbit with our program. As the USB cable provides power for the Microbit, the program begins running, and illuminates the LEDs as expected. If we press the Microbit reset button, the program runs from the beginning as expected.
Furthermore, if we remove the USB cable (removing the power source), and then re-cable the USB cable (providing power once more), the Microbit immediately runs the program. This shows to us we have successfully written the program to the Microbit's flash memory as it is persistent across power on/off cycles.
I note that when we power the Microbit via the USB cable, a yellow LED on the rear of the Microbit near the USB port is illuminated.
What the problem is ...
Let's now bring the Max:bot back into the fold ...
The Max:bot has a battery pack and (it would seem) provides power to the Microbit independently of the USB cable.
If we do not have the USB cable plugged into the Microbit, and we seat the Microbit in the Max:bot connector, and we turn on the Max:bot, then the Microbit appears to power on but does not run the program stored in its flash.
The Microbit instead initialises with this sequence shown on its LEDs.
I note that when powered via the Max:bot, the aforementioned yellow LED on the rear of the Microbit near the USB port does not turn on.
The question is then, why doesn't the Microbit run the flashed program when it is seated in and powered by the Max:bot.
A final observation ...
The following sequence does run the program:
have the Max:bot powered off
cable the USB to the Mac (Microbit powers on, loads program from flash)
turn on the Max:bot
uncable the USB
The question then is why is the USB required to be connected for the Microbit to boot from flash? (Because it's not practical to do so when you've got a program that actually drives the bot around).

From the images you have shared of the LEDs on the micro:bit when it is in the Max:bit it appears to be entering "Bluetooth Pairing Mode". This mode is entered when holding down buttons A and B on the front of your micro:bit while powering on the device. The signal for those buttons are also available on the edge connector.
My assumption here is that Max:bit is using P5 and P11 and so it appears to the micro:bit that button A and button B are being held down when Max:bit is powered.
Looking at the assembly guide it would appear that there are some LED strips that might be the culprit for this.

Related

How does JTAG flash memory programming work?

I am currently using Xilinx ZCU106 board, and I am curious about How does JTAG support flash memory programming. I can upload the boot images or hardware logic just by connecting JTAG USB cable to USB connector at the ZCU106 Board, and press the flash button on the host PC. By doing this it looks like the QSPI Flash holds the boot images or hardware logic image and the system initializes itself by using this image. It seems like a magic, and I want to know about the detail.
So far I understood is that I can access JTAG interface via USB cable (thanks to the FTDI chip?), and JTAG boundary-scans the devices connected to it.
However the problem is here, I couldn't find the link between JTAG and QSPI Flash (MT25QU512ABB8ESF-0SIT). I searched several references, including manual of QSPI Flash (MT25QU512ABB8ESF-0SIT, https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/mt25q/die-rev-b/mt25q_qlkt_u_512_abb_0.pdf) but there seems no port for JTAG (such as TDI, TDO, and TCK), but only SPI.
So the first assumption, I thought on the JTAG chain maybe there is a SPI controller to flash the memory. However I couldn't find any clue on the references that I've read so far that a SPI controller exists on the chain or even a SPI controller that controls the QSPI flash really exists. And the second assumption, I thought PS- ARM Cortex A53- TAP (?) does the magic. PS TAP receives JTAG signal and processes the JTAG command. To be precise, let's say about flash memory programming case, then there is like a JTAG command for write data on the flash memory via SPI.
Among these two, I wonder if there is the answer. One thing for the last, if the second one suppose to be the answer, then the processor (Cortex A53) should implement the functionalities by hardware logic to parse Flash write/erase command signal from JTAG interface and let the SPI controller that the system includes perform the write/erase job? Somewhere I read that the JTAG itself supports writing data on the Flash memory but everything I could find was just TDI, TCK, TDO, TMS, and TRST ports which does not fit in any port of QSPI Flash.
Probably I am confusing a lot of concepts very much, but I want to know about the exact mechanism behind the scene on JTAG flash memory programming.
Normally, it will do with the following sequence:
Send some software to target processor in RAM
Send data to target processor (in RAM)
Trigger execute command to store data into the flash memory.
Now the expected data are available in flash memory.

Armbian - how to turn off a hard drive connected on SATA

I have an Orange Pi + 2 single board computer with the ability to connect an external hard drive via SATA.
Armbian is installed on the hard disk, the bootloader is in the onboard memory of the board.
Any command to turn off the device leads to the same result: the indicators on the board go out, it is no longer available via SSH, but the hard disk, any devices connected via USB continue to work, and the image via HDMI is also displayed on the screen.
How to completely turn off the device so that the hard drive stops correctly?
I believe that if you are capable of powering the device off using the operating system's menu, then it should be safe to cut the power off from the device itself. I have a raspberry pi 4 and have a little USB-C adapter that has a simple power switch which makes this concept very convenient for me. Cutting power to a turned-on, working device is very dangerous as it can damage critical files that could be being written. For this reason, it is probably smart to back up the device and also make sure that you are powering the device off through the operating system so that it can finish editing core files in case it needs to.

How to detect, when a juul started charging? Over ubs (vb.net)

I have a juul, a charger, and a pc. The pc has usb ports. Thats clear.
When i plug a mouse, keyboard or any HID device, the pc can recognise these, but when i plug the charger, nothing happened.
I'm try to watch the connected usb devices, with the "USBDeview" by NirSoft. The software cant list the charger.
How can I detect, when any specified stuff connected via usb? Now the "stuff" is the juul charger.
Thanks for any help, I tried to make it simple.
If it's just a charger, it has nothing to do with the USB bus aside from drawing 5V from its power. I.e. it may only have DC power pins (+, -), without the data pins (D+, D-). In which case, your OS won't notice anything was plugged in.
Image from Wikipedia

how the usb spi flashing device write program to atmega?

the atmega microcontrollers have the internal programmable memory.So the usb flash device write data to internal memory of atmega through spi or it store the program and works as slave?i also want to know can the atmega get program,file in the MicroSD and run without internal memory or it need to run a program in internal disk then including the program in MicroSD?i don't know how the process work in atmega microcontroller.
There are several ways to program the AVR:
Using an external programmer. The Chip is in reset state during this. Then the programmer uses special a special protocol to directly write to the flash inside the controller. This is how your USB programming device probably writes code to the AVR. There are several protocols for this, but the most common one uses the same pins that are used by SPI. You should not confuse them just because of that ;-).
The controller writes the program itself. The chip is actively executing a program. That program on the chip fetches the instructions from e.g. a sd card and using the SPM instruction to copy it to local flash.
The AVR can only fetch instructions from it's own flash memory - you cannot execute directly from RAM or from any other external source.
The best answer for this question you can find at the end or middle of datasheet for AVR device (eg ATMEGA 328P-PU). If you are using some flashing device connected with computer, there is some initialization sequence after start and then there are send some 4 Bytes commands that tels microcontrolers, where to store values to flash and/or eeprom, fuse bits, or cares about erasing etc. There is also posible to read ID of chip.
Atmega microcontroler can be also programmed in paralel mode, where are some bits used for sending commands that tels, what to do with data on data bit.
If you ask about downloading program from SD card or any other device, there is possible to write to the flash through SPM, as there was told above. Some devices do not have part of flash for downloader - if I remember ATMEGA 48, and devices, that have configurable part of memory usable also for downloader, that can handle this, eg. ATMEGA 88, 168, 328. So if you want to download program from SPI, USART, TWI, etc, you need to configure fuse bits and create downloader that will do it for you. I am not sure, how ATMEGA 48 do this, but there si probably possible to write whole flash by SPM instruction.
However the best answer you can find in the datasheet. On pages folowing 255 you can find further information. http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf

Laptop USB port makes 2V 60Hz sine wave on pwm ports?

When I connect my Arduino Mega or Uno to my laptop (HP Pavilion dv6 Windows 7 64 bit) via usb it creates a 2V 60Hz sine wave in the pwm digital pins I am using (2V sine wave when digitalWrite to Low and 5V very noisy pwm when analogWrite is used), and smaller amp sine waves in all the other pins. If I plug either of the boards into a different computer, its totally fine and all the arduino pins give proper 0V or pwm signals. I did not have this problem 2 weeks ago when I ran it, but ran it again today and discovered this problem. The arduino does not appear to have suffered any permanent damage, as it still runs fine on other computers.
The only potentially notable thing I've done in between those two runs was accidentally try to run a motor off an arduino plugged into the laptop that needed more current than the arduino could source ( :$ ). The motor whined but nothing else happened in the second before I unplugged it. Should that be of interest, I only did it on one usb port, and both usb ports are showing this strange sine wave behavior.
Thoughts on what is going on? Is this something I can fix? Is it still safe to program the arduino with my laptop? (Which I can still do, the pins just behave funny until I move it to another computer). I am not able to install software on the other computer (not mine) so cannot do my arduino programming from there.
Thanks!
I had a similar problem between computers and laptops...
My problem was I was running USB power from my computer and a benchtop power supply to some of the digital inputs.
The solution was to cut the trace to isolate USB power from V-in.
This is explained here for Arduino and here for teensy3.1.
....although I didn't measure the signal, there was an overriding noise that limited the PWM output I could achieve...