ah- / anne-key

Firmware for Anne Pro Keyboard written in Rust
Apache License 2.0
567 stars 32 forks source link

Anne Pro 2 support? #70

Open jedahan opened 6 years ago

jedahan commented 6 years ago

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

hdhoang commented 6 years ago

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 commented 6 years ago

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

therealprof commented 6 years ago

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 commented 6 years ago

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

ah- commented 6 years ago

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

MvEerd commented 6 years ago

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](https://user-images.githubusercontent.com/12560315/44931022-22872200-ad15-11e8-8e7f-fe21e53e7a45.jpg) ![anne_pro_2_right](https://user-images.githubusercontent.com/12560315/44931023-22872200-ad15-11e8-93b6-27c6bb1b7b64.JPG)
jedahan commented 6 years ago

img_20180831_161207 img_20180831_161227 img_20180831_161300 img_20180831_161324 img_20180831_161328

jedahan commented 6 years ago

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

jedahan commented 6 years ago

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 commented 6 years ago

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

ah- commented 6 years ago

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

therealprof commented 6 years ago

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 commented 6 years ago

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- commented 6 years ago

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

CC2541 is the same chip as on the previous Anne.

therealprof commented 6 years ago

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 commented 6 years ago

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

therealprof commented 6 years ago

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

U2 U4 U6 U8 U3 U1

therealprof commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

@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- commented 6 years ago

@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 commented 6 years ago

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- commented 6 years ago

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 commented 6 years ago

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- commented 6 years ago

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- commented 6 years ago

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 commented 6 years ago

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- commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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

si973mo commented 5 years ago

Can you help me with a problem with my Anne pro2 the backlight will not work when I press fn2 and 9 it will not show up any colours

MycroftHolmes1989 commented 4 years ago

Has anyone tried dabbling with this anymore? Ducky One 2 Mini now has a QMK port, and I feel like such a fool for choosing Anne Pro 2 over it.

DonaldTsang commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

hargoniX commented 4 years ago

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

hargoniX commented 4 years ago

@therealprof https://github.com/probe-rs/probe-rs/issues/172 just as a tracker for progress on this.

theobarberbany commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

hargoniX commented 4 years ago

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 commented 4 years ago

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 :tm:

ah- commented 4 years ago

Wow! Does flashing and debugging work?

hargoniX commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

hargoniX commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.