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

Use uf2families.json for UF2 family info #39

Open
bcr opened this issue Apr 28, 2021 · 3 comments
Open

Use uf2families.json for UF2 family info #39

bcr opened this issue Apr 28, 2021 · 3 comments

Comments

@bcr
Copy link

bcr commented Apr 28, 2021

Per microsoft/uf2#46 there is now a JSON file that can be used to generate the values in hf2/src/bininfo.rs

I can take a stab at making a script to auto-update this for you.

For your case, these work for instance:

➜  hf2-rs git:(master) ✗ cat uf2families.json | jq -r '.[] | "\(.id) => Self::\(.short_name),"' | sed "s/^\(0x.\{4\}\)/\1_/"
0x1657_3617 => Self::ATMEGA32,
0x1851_780a => Self::SAML21,
0x1b57_745f => Self::NRF52,
0x1c5f_21b0 => Self::ESP32,
0x1e1f_432d => Self::STM32L1,
0x202e_3a91 => Self::STM32L0,
0x2146_0ff0 => Self::STM32WL,
0x2abc_77ec => Self::LPC55,
0x300f_5633 => Self::STM32G0,
0x31d2_28c6 => Self::GD32F350,
0x0424_0bdf => Self::STM32L5,
0x4c71_240a => Self::STM32G4,
0x4fb2_d5bd => Self::MIMXRT10XX,
0x53b8_0f00 => Self::STM32F7,
0x5511_4460 => Self::SAMD51,
0x5775_5a57 => Self::STM32F4,
0x5a18_069b => Self::FX2,
0x5d1a_0a2e => Self::STM32F2,
0x5ee2_1072 => Self::STM32F1,
0x6478_24b6 => Self::STM32F0,
0x68ed_2b88 => Self::SAMD21,
0x6b84_6188 => Self::STM32F3,
0x6d09_22fa => Self::STM32F407,
0x6db6_6082 => Self::STM32H7,
0x70d1_6653 => Self::STM32WB,
0x7eab_61ed => Self::ESP8266,
0x7f83_e793 => Self::KL32L2,
0x8fb0_60fe => Self::STM32F407VG,
0xada5_2840 => Self::NRF52840,
0xbfdd_4eee => Self::ESP32S2,
0xc47e_5767 => Self::ESP32S3,
0xd42b_a06c => Self::ESP32C3,
0xe48b_ff56 => Self::RP2040,
0x00ff_6919 => Self::STM32L4,
@bcr
Copy link
Author

bcr commented May 1, 2021

This will update bininfo.rs in-place

#!/bin/sh
uf2info=`curl https://raw.githubusercontent.com/microsoft/uf2/master/utils/uf2families.json`

map=`echo $uf2info | jq -r '.[] | "            \(.id) => Self::\(.short_name),"' | sed "s/\(0x.\{4\}\)/\1_/"`
perl -0777 -i -pe \
 "s/(match val {\\n).*(_ => Self::UNKNOWN\(val\),\\n)/\$1$map\\n            \$2/s" \
 bininfo.rs

families=`echo $uf2info | jq -r '.[] | "    \(.short_name),"'`
perl -0777 -i -pe \
 "s/(pub enum FamilyId {\\n).*(    UNKNOWN\(u32\),\\n)/\$1$families\\n\$2/s" \
 bininfo.rs

@jacobrosenthal
Copy link
Owner

Thanks!
we keep the vid pid pairs over at

0x1D50 => vec![0x6110, 0x6112],

Ill probably do something pure rust at some point, but whatever solution you come up with would be fine for now.

@bcr
Copy link
Author

bcr commented May 2, 2021

Well, I'm not sure how to fix the VID / PID problem -- I tried to make the family field in the UF2 spec as normalized as I could. But as far as VID / PID I'm not sure how to approach it.

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

No branches or pull requests

2 participants