Skip to content
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

Updated the Ox64 flashing guide #32

Merged
merged 7 commits into from
Feb 10, 2024
Merged

Updated the Ox64 flashing guide #32

merged 7 commits into from
Feb 10, 2024

Conversation

Pavlos1
Copy link
Contributor

@Pavlos1 Pavlos1 commented Feb 10, 2024

Many small changes and rearrangements. Includes a new section on using non-Pico UART adapters.

Quick formatting note. I have changed some of the code listings to a different style to allow for blank lines, i.e.

----
line 1
line 2

line 3
----

It may be worth considering adopting this style more broadly for the sake of consistency. We can even do syntax highlighting as follows, but it looks a bit strange with the current CSS / rouge configuration.

[source,shell]
----
cd /some/path
----

Also general formatting cleanups and clarifications.
Debian will pull in those other packages by itself.
@giorez
Copy link
Contributor

giorez commented Feb 10, 2024

i suggest to replace all the path recurrencies from "/Downloads/ox64" to "/ox64", or something easier to set globally for low end users, like me. i always had problems following instructions and set the proper path, also because when you clone a repo the folder is created automatically.

@giorez
Copy link
Contributor

giorez commented Feb 10, 2024

regarding appendix about non-pico uart devices is a great idea. i was trying to use stm32xxx + black magic. it's very cheap, but unfurtunately i'm stuck with flashing instructions, and i need some help. do you have any tip?

@Pavlos1
Copy link
Contributor Author

Pavlos1 commented Feb 10, 2024

regarding appendix about non-pico uart devices is a great idea. i was trying to use stm32xxx + black magic. it's very cheap, but unfurtunately i'm stuck with flashing instructions, and i need some help. do you have any tip?

As you mentioned, that appendix section should cover most of it. Where are you getting stuck?

@giorez
Copy link
Contributor

giorez commented Feb 10, 2024

regarding appendix about non-pico uart devices is a great idea. i was trying to use stm32xxx + black magic. it's very cheap, but unfurtunately i'm stuck with flashing instructions, and i need some help. do you have any tip?

As you mentioned, that appendix section should cover most of it. Where are you getting stuck?

at the moment I cant check the step i did until now, but i will post here more infos in next days. thanks

@x1y x1y merged commit 0f13775 into pine64:main Feb 10, 2024
@giorez
Copy link
Contributor

giorez commented Feb 16, 2024

regarding appendix about non-pico uart devices is a great idea. i was trying to use stm32xxx + black magic. it's very cheap, but unfurtunately i'm stuck with flashing instructions, and i need some help. do you have any tip?

As you mentioned, that appendix section should cover most of it. Where are you getting stuck?

do you know how to program a stm32 as blackmagic? i have a FT232RL and i m trying to prepare a Uart adaptor to flash linux on ox64. no guides on the web are working for me. thanks

@Pavlos1
Copy link
Contributor Author

Pavlos1 commented Feb 16, 2024

regarding appendix about non-pico uart devices is a great idea. i was trying to use stm32xxx + black magic. it's very cheap, but unfurtunately i'm stuck with flashing instructions, and i need some help. do you have any tip?

As you mentioned, that appendix section should cover most of it. Where are you getting stuck?

do you know how to program a stm32 as blackmagic? i have a FT232RL and i m trying to prepare a Uart adaptor to flash linux on ox64. no guides on the web are working for me. thanks

FT232RL apparently won't work for flashing the Ox64 itself. (Although you can try playing with baud rates to see if it helps.)

Re: STM32, what hardware do you have?

@giorez
Copy link
Contributor

giorez commented Feb 16, 2024

I have stm32f103c8t6 know also as bluepill, it's a compatible UART adaptor in the list of ox64. I tryed to put blackmagic on to stm32f103c8t6 throught FT232RL. I'm not using FT232RL to flash ox64, sorry for misunderstanding.

@Pavlos1
Copy link
Contributor Author

Pavlos1 commented Feb 16, 2024

I haven't used blackmagicdebug before. But in any case you'll have to be more specific regarding where you got stuck.

The general flow should be something like:

  1. Compile blackmagicdebug (make PROBE_HOST=stlink BLUEPILL=1)
  2. Move bluepill jumpers to boot from System memory
  3. Connect your FT232RL to the bluepill's USART1 (PA9/PA10)
  4. Use st-flash to write your compiled blackmagicdebug firmware to the bluepill
  5. Move bluepill jumpers to boot from Main Flash memory
  6. Check whether your bluepill now shows up as a USB serial adapter. This should expose USART3 (PB10/PB11); simple way to check is to connect those pins together and see if your USB serial inputs get echoed back to you.

Edit: it might expose USART2 (PA2/PA3) instead.

Resources:
https://www.electronicshub.org/getting-started-with-stm32f103c8t6-blue-pill/
blackmagic-debug/blackmagic#1632
https://github.com/mmoskal/blackmagic-bluepill

@giorez
Copy link
Contributor

giorez commented Feb 16, 2024

ciao Pavlos1, these are the steps i followed.



First, download BlackMagic firmware that allows it to act as a serial adapter (more info on https://github.com/koendv/blackmagic-firmware/blob/master/INSTALL.md)

cd ~/ox64
mkdir -p stm32f103c8t6
cd ~/ox64/stm32f103c8t6
wget https://github.com/koendv/blackmagic-firmware/releases/download/v1.10.2/blackmagic-firmware.zip
unzip blackmagic*.zip
mv blackmagic-firmware-v1.10.2 blackmagic

Set boot jumpers of STM32f103c8t6 board for boot from rom: Boot0=1, Boot1=0.
Connect STM32f103c8t6 to a USB-Serial adapter (i.e FT232RL) with A9 to Rx, A10 to Tx, GND to GND, 3v3 to Vcc

== Put the Stm32f103c8t6 board into programming mode.

Apply power by plugging the USB cable to PC. Press the Reset button.

Check the USB-serial adapter to be /dev/ttyUSB0
ls /dev/ttyUSB0

Upload the firmware:
cd ~/ox64/stm32f103c8t6/blackmagic/bluepill
stm32flash -w blackmagic_allinone-bluepill.bin /dev/ttyUSB0

After upload, set boot jumpers for boot from flash: Boot0=0, Boot1=0.
Remove USB-serial adapter

Connect Stm32f103c8t6 to usb.

After flashing, verify that you have two serial interfaces (when the STM32f103c8t6 is connected to your PC):

ls /dev/ttyACM*

Expected result:
/dev/ttyACM0
/dev/ttyACM1

Next, connect the Ox64 board to the STM32f103c8t6 according to the following wiring diagram:

OX64 STM32
uart0_Tx_GPIO14_pin1 <-> Rx_A2 [for flashing]
uart0_Rx_GPIO15_pin2 <-> Tx_A3 [for flashing]

Rxd_GPIO17_pin31 <-> ???? [for serial console]
Txd_GPIO16_pin32 <-> ???? [for serial console]
gnd_pin38 <-> gnd_pin38/3
vbus5v_pin40 <-> vbus5v_pin40



Regarding ox64 flashing both DevCube and CLI method are reported as succesfull.

Now if I do
minicom -b 2000000 -D /dev/ttyACM1

I have ACM1:

[I][MBOX] Mailbox IRQ Stats:
[I][MBOX] Peripheral SDH (33): 0
[I][MBOX] Peripheral GPIO (60): 0
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0

I cant see ACM0 for serial console
I don't know wich pin to use on STM32f103c8t6 for serial console.

Any help is appreciated. thanks.

PS on dmesg I have:
[11140.149794] usb 2-1.3: new full-speed USB device number 16 using ehci-pci
[11140.261778] usb 2-1.3: New USB device found, idVendor=1d50, idProduct=6018, bcdDevice= 1.09
[11140.261789] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[11140.261795] usb 2-1.3: Product: Black Magic Probe (ST-Link/v2) v1.10.2-dirty
[11140.261800] usb 2-1.3: Manufacturer: Black Magic Debug
[11140.261804] usb 2-1.3: SerialNumber: E0C5C103
[11140.262990] cdc_acm 2-1.3:1.0: ttyACM0: USB ACM device
[11140.263801] cdc_acm 2-1.3:1.2: ttyACM1: USB ACM device

@Pavlos1
Copy link
Contributor Author

Pavlos1 commented Feb 17, 2024

You seem to be getting the expected results. The blackmagicdebug firmware only gives you one exposed serial port (/dev/ttyACM1), which you have already used to talk to your Ox64. So you have to manually swap the connections to get your Linux serial console.

The other device (/dev/ttyACM0) talks directly to the STM32 chip; it's not a serial pass-through. (It's used for GDB debugging of a connected target, i.e. blackmagicdebug's primary purpose.)

If you want it to behave like your Pico does, you'd have to write your own firmware for it.

EDIT: you might not have to write your own: https://github.com/r2axz/bluepill-serial-monster

@giorez
Copy link
Contributor

giorez commented Feb 17, 2024

thanks a lot!!! I'have been able to get STM32 to act as double UART serial console adapter. I just PR the updates. 958e1aa
Do you think I have wrong behaviour to edit contents of Ox64? I noted the @x1y is not pulling in my requests.

@x1y
Copy link
Collaborator

x1y commented Feb 17, 2024

thanks a lot!!! I'have been able to get STM32 to act as double UART serial console adapter. I just PR the updates. 958e1aa Do you think I have wrong behaviour to edit contents of Ox64? I noted the @x1y is not pulling in my requests.

It's because you guys are still working on it and discussing it. You can turn it into a draft and then when it's finished as "ready for review" as explained under https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request so that I know when I can merge it.

@giorez
Copy link
Contributor

giorez commented Feb 17, 2024

i see. As far as I know the main structure of the document is done and ready for revision, if @Pavlos1 agrees. Thanks Pavel, thanks @x1y for all your support in my first github PR experience.

@Pavlos1
Copy link
Contributor Author

Pavlos1 commented Feb 17, 2024

i see. As far as I know the main structure of the document is done and ready for revision, if @Pavlos1 agrees. Thanks Pavel, thanks @x1y for all your support in my first github PR experience.

Technical content looks correct. I have some formatting/wording changes I would make, but I'll do those in a separate PR if/when #38 is merged in some form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants