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

Anne Pro 2 support? #70

Open
jedahan opened this issue Aug 25, 2018 · 61 comments
Open

Anne Pro 2 support? #70

jedahan opened this issue Aug 25, 2018 · 61 comments

Comments

@jedahan
Copy link

jedahan commented Aug 25, 2018

I know it was just announced, but wondering if we could have a tracking issue for what chipset it is, etc.

@hdhoang
Copy link
Collaborator

hdhoang commented Aug 26, 2018

sure thing! Such info would fit nicely in the book, even if we don't have any code for it. I'll be on the look out for them

@jedahan
Copy link
Author

jedahan commented Aug 26, 2018

Okay I ordered one, should be here in a few days, will see what the differences are

@therealprof
Copy link

I also ordered one last Saturday from China. Although it was on backorder very much to my surprise it already arrived today in Germany...

@jedahan
Copy link
Author

jedahan commented Aug 31, 2018

Got mine in too, what commands would be helpful? lspci? lsusb? opening it up and taking pictures?

@ah-
Copy link
Owner

ah- commented Aug 31, 2018

Exciting! The latter, close up pictures of the chips so we can see if they're the same.

@MvEerd
Copy link

MvEerd commented Aug 31, 2018

The included images were posted in the Discord by Flashquark, the chip seems to be a HT32F52342
Higher quality images of the PCB would be much appreciated though!

HT32F52342-52_Datasheetv120.pdf

Click to see images

anne_pro_2_left
anne_pro_2_right

@jedahan
Copy link
Author

jedahan commented Aug 31, 2018

img_20180831_161207
img_20180831_161227
img_20180831_161300
img_20180831_161324
img_20180831_161328

@jedahan
Copy link
Author

jedahan commented Aug 31, 2018

hmm these aren't as good as the ones you already have

@jedahan
Copy link
Author

jedahan commented Aug 31, 2018

It does look like there is something like DFU mode if you hold esc while plugging in the usb c. Not sure if we can inspect that, maybe with a facedancer or something.

@therealprof
Copy link

@MvEerd Sure thing, anything in particular you'd like to see?

@ah-
Copy link
Owner

ah- commented Aug 31, 2018

Got a pic of the bluetooth chip? It's under the little metal shield on the left of the board.

@therealprof
Copy link

Hm, not sure I want to remove the can... There's so much plastic on the board and I'm not not I can protect that...

@therealprof
Copy link

Lol, the can is only hold in place by tabs, it's a CC2541. Need a photo? I'd have to fire up the microscope then, it's barely imageable using a camera.

@ah-
Copy link
Owner

ah- commented Aug 31, 2018

Cool, that's all I wanted to know :)

CC2541 is the same chip as on the previous Anne.

@therealprof
Copy link

Here you go: It's as high-res as I can do right now and best quality GH would allow me to upload. ;)

left
middle
right

@therealprof
Copy link

@ah- Is the BT chip really that relevant for anne-key?

@therealprof
Copy link

therealprof commented Aug 31, 2018

Here's the rest of the chips close up...

U2
U4
U6
U8
U3
U1

@therealprof
Copy link

My excitement of the Anne Pro 2 is a bit dampened. Not sure whether the Anne Pro is the same, but the 2 is really quirky in BT operation and the key mapping is rubbish (the problem being they should either implement mapping keycodes for other layouts than US or preferably add a layout indication the HID profile as defined in HID Review Request 42) which makes it pretty much unusable for for me at the moment.

@mainrs
Copy link

mainrs commented Sep 20, 2018

@therealprof I was thinking about getting the Anne Pro / Anne Pro 2 to tinker around with the firmware a bit. What do you mean by "the keymapping is garbish"?

@therealprof
Copy link

@sirwindfield They don't indicate the keyboard layout in the communication so it will automatically use the keyboard layout which is very annoying if you're on a laptop with a foreign layout. Should be trivial to indicate a US layout in the HID profile to allow seamless swapping between keyboards...

I was kind of shocked to learn to keyboards still use those idiotic arbitrarily chosen fixed scancodes instead of just sending the translated characters...

@ah-
Copy link
Owner

ah- commented Sep 20, 2018

@sirwindfield, if you want to tinker around you might want to get a Anne Pro 1, STM32 has better support for open source. Also Cortex M3 instead of M0+ :)

Unless you want to help with bringup, then get the 2.

@mainrs
Copy link

mainrs commented Sep 20, 2018

Are there more keyboards that are flashable? I was generally thinking of getting my first mechanical and looked for some time online but a lot of them aren't even available in my country (Germany).

@ah-
Copy link
Owner

ah- commented Sep 20, 2018

Oh yeah, there are tons. However, they usually don't have Bluetooth and tend to be a bit more expensive. If you just want to play around a bit I'd recommend getting one with QMK, if you like Rust or love reverse engineering get the Anne Pro.

@mainrs
Copy link

mainrs commented Sep 20, 2018

Unless you want to help with bringup, then get the 2.

@ah- By bringup you mean helping out writing the firmware right? Not sure what is means :/
The thing is, I can't seem to find any Anne V1 anymore. They are all sold out sadly.

@ah-
Copy link
Owner

ah- commented Sep 20, 2018

Basically figuring out what tools to use to flash / debug the chip, how to configure them, reading the datasheet to figure out how to toggle/read pins etc. So the rather low level things vs. adding higher level features like keyboard shortcuts or similar.

@ah-
Copy link
Owner

ah- commented Sep 20, 2018

Actually, I've got a spare AP 1 that I don't use, if you want it I'll send it to you for free. It's got the red switches, don't really like them and have enough keyboards.

Send me an email (see profile) with your address if interested, no strings attached.

@hdhoang
Copy link
Collaborator

hdhoang commented Sep 21, 2018

Basically figuring out what tools to use to flash / debug the chip, how to configure them, reading the datasheet to figure out how to toggle/read pins etc.

I see you have a todos.txt in gitignore, could you track it here too? We can then tease it out into the book sections.

@ah-
Copy link
Owner

ah- commented Sep 21, 2018

I guess this thread is enough tracking for now, getting it to work won't be super easy since I haven't immediately found great resources for the Holtek Cortex M0 chips.

https://github.com/ChaoticConundrum/openocd-ht32 seems to add support to openocd, but it's in a fork not in mainline etc. The nice thing about the stm32 in the original Anne Pro was that it has great support in the open source ecosystem.

@felipesere
Copy link

Would it be possible to use https://github.com/rust-embedded/cortex-m-quickstart
and the details from https://www.holtek.com/documents/10179/116711/HT32F52342_52_Datasheetv150.pdf to get started with a compilation?
I don't have an Anne2 myself, but I am curious if I can use an Anne2 and this repo to create a couple of layouts that allow me to input US keystrokes on a british OS :)

@MatiasPuhakka
Copy link

What's the latest status on Anne Pro 2 support?

@DonaldTsang
Copy link

DonaldTsang commented Jan 18, 2020

It's 2020 and I am basically hoping for the same thing for cheap 61 key keyboards

Has anyone looked into...
https://github.com/fcoury/node-anne-pro (JS)
https://github.com/Blucky87/AnneProCLI (Python)
https://github.com/leonardlorenz/anne-pro-community-app (Java)
https://github.com/fcoury/electron-anne-pro (JS)

@MycroftHolmes1989 don't fear, we might get to it... I might contact the company that makes it.

Who want to send send a message to their socials for help?
https://www.facebook.com/annepro2/ https://www.instagram.com/anne_pro_2/
Their email is info@annepro2.com and the company is service@obins.net

@hargoniX
Copy link

hargoniX commented Mar 7, 2020

So I've been looking into implementing a HAL for the HTF32F523 series of chips in rust (I guess this would be the first step for this goal?). And got myself some hardware (specifically HT-ESK32-30501). Now I'm currently struggling to find any open source software that is able to communicate with the on board debugger, does someone here have any suggestion for that or do I have to implement support for it in something popular like openocd?

@therealprof
Copy link

Instead of going for OpenOCD I'd probably go for https://probe.rs/ first.

@hargoniX
Copy link

hargoniX commented Mar 7, 2020

Oh wow I didnt know it had gotten that far since i last looked at it! Definitely will do!

@hargoniX
Copy link

hargoniX commented Mar 8, 2020

@therealprof probe-rs/probe-rs#172 just as a tracker for progress on this.

@theobarberbany
Copy link

@hargoniX I'd be happy to donate some time if you get anywhere with that! I've not got any real experience, but would be willing to try learn :)

I've been toying with the idea of trying but also don't really know where to start...

@hargoniX
Copy link

Quiiiiiick update, I've just managed to get cargo-flash to flash some random ELF onto my dev board so I'll be landing a PR for that in cargo-flash soon.

@theobarberbany First of we'd have to look into a PAC, https://github.com/rmsthebest/ht32f523x2 is a thing but I am not sure how up to date/maintained etc it is. Usually though the process of building a PAC is mostly automated as one can run svd2rust over a manufacturer supplied SVD file and generate lots of (hopefully) correct code from that. Afterwards we'd be looking into writing an actual HAL + presumably USB support (not defined in embedded-hal afaik). And then on top of that a full keyboard firmware like this one.

@blu3r4d0n
Copy link

@hargoniX Any updates? Is there anything I could possibly do to help?

@hargoniX
Copy link

So I created https://github.com/ht32-rs/ and yesterday published my own set of PACs (for all Holtek chips), see here and here. What we'd have to do now is look into building a HAL for the ht32f52342_52 variant of the second crate. Which essentially means reading this document and writing code that implements embedded-hal traits for it.

If we want to use this HAL for Anne Pro 2 firmware ASAP it would be very useful to know which peripherals we should focus on so somebody should make a list of that and file an issue for that over at https://github.com/ht32-rs/ht32f5xxxx-hal

I was gonna look into writing code for the clock setup next weekend (and probably beyond that, dunno how long that takes me) and after that look into implementing the necessary peripherals so it would certainly also be useful if someone wanted to help with the peripherals (especially with USB of course).

Apart from that nothing comes to mind @philipmnelson

@hargoniX
Copy link

hargoniX commented Jun 7, 2020

And for another update, I'm done with the clock implementations as well as the GPIO implementation (see https://github.com/ht32-rs/ht32f5xxxx-hal) and will move on to the peripheral implementations for the chips posted far above by now soon ™️

@ah-
Copy link
Owner

ah- commented Jun 8, 2020

Wow! Does flashing and debugging work?

@hargoniX
Copy link

hargoniX commented Jun 8, 2020

On the HT32 chip it has been working since https://github.com/ah-/anne-key/issues/70#issuecomment-596231100 was closed^^ Now it can already blink LEDs \o/

@hargoniX
Copy link

And for another update, I just got SPI working, yesterday got I2C working-ish so the only two things that's left now is UART and USB, how hard can USB be 😉

@MycroftHolmes1989
Copy link

MycroftHolmes1989 commented Jun 15, 2020

Quick question: once the USB part is implemented, will it be possible to run something like QMK on it?

@hargoniX
Copy link

hargoniX commented Jun 15, 2020

QMK is not at all related to what I am doing here, I'm implementing the Rust abstractions required to do sensible embedded development on the Holtek chip, QMK is a C firmware project that has absolutey 0 idea on how to deal with the Rust abstractions what so ever.

TLDR; QMK is a different language and compatability between Rust embedded and it = 0 -> No

Edit:
That being said porting QMK to this chip / keyboard is conceptually not much different from doing the same thing in Rust but I have neither the motivation nor the C knowledge to do any of that. I tried to take a look at the C code Holtek provides as a library for their chip, but the download link on their page is broken so I have no means to access it, if one would get that C code they would effectively done with the work I am doing right now in Rust and the only effort would be the QMK port. However I don't have any motivation in dealing with a random Taiwanese company to get them to fix their download links just to port QMK over the Anne Pro when we already have something in Rust cooking here.

If anyone actually wants to do this though and can't get Holtek to fix their links feel free to use my code as a basis for a QMK port once its done, I'm sure that's gonna make some people happy as well.

A third option would be to add a compatability layer between Rust's embedded-hal and USB traits and C which I'm not willing to do though, if someone else finds the motivation for that feel free.

@MycroftHolmes1989
Copy link

MycroftHolmes1989 commented Jun 15, 2020

As far as I remember, there was someone who ported a few functionalities of QMK to Rust. I will try to find that project. If anything remotely close works with Anne pro 2, it will be a blessing.

Edit: I was expecting compatibility with something like this: https://github.com/TyberiusPrime/keytokey

@hargoniX
Copy link

U(S)ART now works as well, will look into USB in the next days/weeks and once I got that done we should be more or less ready to go with porting!

@Codetector1374
Copy link

Codetector1374 commented Jun 25, 2020

For a QMK port you will need to port ChibiOS. I have a port of ChibiOS for HT32F165x, at github.com/OpenDucky
I recently ported QMK to a Ducky keyboard which uses the HT32F1654. It looks very close to the F5 series that they use on the Anne Pro.

@MycroftHolmes1989
Copy link

MycroftHolmes1989 commented Jun 27, 2020

For a QMK port you will need to port ChibiOS. I have a port of ChibiOS for HT32F165x, at github.com/OpenDucky

The question is, does Anne Pro 2 have enough RAM and ROM for ChibiOS + QMK? Otherwise, it might be worthwhile to cherry-pick the features we need and port them to Rust.

@Codetector1374
Copy link

Codetector1374 commented Jun 27, 2020 via email

@Codetector1374
Copy link

Codetector1374 commented Jun 27, 2020 via email

@Codetector1374
Copy link

Honestly I am thinking about making a rust port of QMK. They really don't use ChibiOS for real. They use it mainly as a good HAL. afaik they run all of their code in the ChibiOS "idle" task. Which is kind of under utilization of an RTOS. But the upside is that any user can easily expand functionality by creating a new thread and not have to worry about the existing core QMK code.

@ah-
Copy link
Owner

ah- commented Jun 27, 2020

I am currently reversing the firmware that is on stock Anne pro 2. Hoping to be able to dump the original boot loader though a custom “firmware”. The goal is to be able to keep the old boot loader with the new firmware. Since it only uses the lower 16K and keeps the ability to roll back to stock if needed. I think that’d be nicer than having to using SWD tool to wipe the chip.

In the old anne you could use the default bootloader to flash your own firmware by just locating it at the right offset hopefully that works on the new one as well.

@Codetector1374
Copy link

I am currently reversing the firmware that is on stock Anne pro 2. Hoping to be able to dump the original boot loader though a custom “firmware”. The goal is to be able to keep the old boot loader with the new firmware. Since it only uses the lower 16K and keeps the ability to roll back to stock if needed. I think that’d be nicer than having to using SWD tool to wipe the chip.

In the old anne you could use the default bootloader to flash your own firmware by just locating it at the right offset hopefully that works on the new one as well.

Well the problem is here that they don't use standard USB-DFU. So we need to figure out what protocol they use. The firmware is loaded at 0x4000. Hence the bootloader uses the lower 16K of flash.

@Codetector1374
Copy link

Obins Kit is very stupid in the sense that it uses a HTTP server to download the firmware. So my plan right now is to write a simple USB DFU thing like this HT32 USBDFU base it at 0x4000 and use local DNS to trick it into downloading the "DFU" as the firmware. This will allow us to dump the protected flash (mainly the bootloder) so we can figure what they do.

@Codetector1374
Copy link

Okay I started a Github Org tracking the re-firmware progress. https://github.com/OpenAnnePro
I have the original bootloader dump uploaded there.

@Codetector1374
Copy link

More progress!
AnnePro2-Tools
This is a small tool I wrote that allow you to flash custom firmware into the main MCU(U2). In theory you can change it to flash the other two by simply changing the target param. But that work is to be tested. Enjoy 😄

@MycroftHolmes1989
Copy link

U(S)ART now works as well, will look into USB in the next days/weeks and once I got that done we should be more or less ready to go with porting!

I hope we get a Rust implementation of the firmware too, for those who don't want to use QMK.

@hargoniX
Copy link

Im still looking into USB, never implemented a USB peripheral in Rust though (and the way Holtek's USB peripheral was built also makes it a bit hard to generalize into the traits from usb-device)

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