Go Down

Topic: LilyGo BadUSB - ATMEGA32U4 - Info & Pinouts (Read 7507 times) previous topic - next topic

Nico_TheDecoder

Mar 24, 2019, 03:02 pm Last Edit: Jul 28, 2020, 12:43 am by Nico_TheDecoder
Updated 28/07-2020


Here is some info about LilyGo BadUSB and you are welcome to add more info about the subject.


After I bought some pieces of LilyGo BadUSB, my first thought was that the board should also be used for anything other than keyboard emulation and evil things.


But first, just a little info about keyboard emulation for non-US:
Finding a library for the Arduino IDE for my Keyboard Layout was a bit difficult, but found "Keyboard_DE" and it works: https://github.com/BesoBerlin/Arduino-German-Keyboard


I've tried searching the web for pinouts, schematic and similar.
But ended up separating one of my own LilyGo BadUSB board, and here are some pictures.

I have put on a label with pinouts, because I always forget which pins are which.
(So many pins  :D )



Found out that it is an ISP connector that is inside and a red LED.

And here are the pinouts:
+5v GND RST SCK MOSI MISO

Pins in Arduino IDE (board is Leonardo):
SCK = 15
MOSI = 16
MISO = 14
LED = 13

Here near the screwdriver we have an LED.


Another picture of PCB



Pinouts https://i.ibb.co/9GdT2JH/Lily-Go-BADUSB-Pinout.jpg



I have also tried playing a bit with SoftwareSerial and works fine with pins 14, 15, 16 (MISO, SCK, MOSI)
https://www.arduino.cc/en/Reference/SoftwareSerial


Board Specs:
Microcontroller: ATmega32u4
Clock Speed: 16 MHz
Operating Voltage: 5V DC
Digital I / O Pins: 4 (Onboard LED = 13, MISO = 14, SCK = 15, MOSI = 16)
USB: 1
Flash Memory: 32KB, but 4KB used by bootloader (Caterina-Leonardo / Arduino Leonardo Bootloader)
SRAM: 2.5 KB
EEPROM: 1 KB



It is also possible to remove LED & resistor.

The resistor near the LED on my device are marked "331" (330 Ω)

After removing the resistor, I drilled a hole with a 0.8 mm drill bit between the 2 pads where the resistor was soldered.



With Pin 13 free, it is possible to have SPI interface with e.g. SD card etc.

SD / µSD card tested & works fine with LilyGo BadUSB board.
(CS / Chip Select Pin = Pin 13)



Link for pictures in high resolution & Original Arduino Leonardo Bootloader HEX:
https://drive.google.com/drive/folders/1NFCk_8VjjQSnWvtUBjm2BaI0zoQtvpTG



Feel free to drop a post/reply about what cool projects you have gotten out of this little board.

Like "BionicRiddle" did.

(Description, Pictures & Code)



Stay safe and stay legal guys/girls!!

BionicRiddle

#1
Jul 05, 2019, 12:07 am Last Edit: Jul 05, 2019, 12:08 am by BionicRiddle
Thanks! I did not know that there was a LED built-in on the board. I repurpose mine as a discord mute indicator using https://github.com/Oxmaster/Discord-mute-indicator
I remapped "Ctrl + <" to "Scroll Lock" using AutoHotKey
I changed some things in Oxmaster's code so it would use pin 13 on the LilyGo


Video: https://public.riddle.nu/cds/lt/discordindicator.mp4

Arduino code: https://public.riddle.nu/cds/lt/DiscordMuteIndicator.ino

Code: [Select]
/*  License
 *
 *  GNU GENERAL PUBLIC LICENSE
 *  Version 3, 29 June 2007
 *
 *  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 *  Everyone is permitted to copy and distribute verbatim copies
 *  of this license document, but changing it is not allowed.
 * 
 *  see LICENSE.txt
 */

/*  DiscordMuteIndicator
 *
 *  Version: 1.0
 *  Date: 24.03.2019
 *
 *  Author: Paul Oleszczyk
 *  Twitter: @oxmstr
 *  Email: paul.oleszczyk@gmail.com
 *  Github: https://github.com/Oxmaster/Discord-mute-indicator
 */

#include <HID-Project.h>

// config ------------------------------------------------------------

/*  which LED will trigger the images
 * 
 *  possible choices:
 *
 *  LED_NUM_LOCK
 *  LED_CAPS_LOCK
 *  LED_SCROLL_LOCK
 *  LED_COMPOSE
 *  LED_KANA
 *  LED_POWER
 *  LED_SHIFT
 *  LED_DO_NOT_DISTURB
 */
#define triggerLed LED_SCROLL_LOCK


const bool mutedMicrophoneImageWhenTriggerLed = 1;            // LED on if triggerLed (scroll lock by default) is ON (1) or OFF (0)

// vars --------------------------------------------------------------


bool micState = 0;                                            // current status of triggerLed (scroll lock by default)

// functions declarations --------------------------------------------

void poll();                                                  // poll the status of the triggerLed
void updateLED();                                             // updates the LED, dependent on the micState

// main --------------------------------------------------------------

void setup()
{
  pinMode(13, OUTPUT);
  BootKeyboard.begin();
}

void loop()
{
  poll();
  updateLED();
}

// functions ---------------------------------------------------------

void poll()
{
  micState = (BootKeyboard.getLeds() & triggerLed) ? 1 : 0;   // compare bit masks if triggerLed (by default scroll lock) is ON or OFF
}

void updateLED()
{
  static bool previousMicState = !micState;
 
  // if there was no change, there is no need to update the LED
  if (previousMicState != micState)
  {   
    if (micState == mutedMicrophoneImageWhenTriggerLed)
    {
      digitalWrite(13, HIGH);
    } else
    {
        digitalWrite(13, LOW);
    }
    previousMicState = micState;
  }
}

// I Love You

Code: [Select]

AutoHotKey:
^VKE2::ScrollLock ; Discord Mute (remap Ctrl + < to ScrollLock
!VKE2::| ; Alt + < fix (Nordic keyboard)
<^>!VKE2::| ; AltGr + < fix (Nordic keyboard)

<3

nightcrawler218

hi,

Thanks for the useful information. I somehow scred up the bootloader. The USB is not getting detected in my Linux Box anymore. tried with
Code: [Select]
lsusb
 &
Code: [Select]
dmesg -w
 command. no device detected. trying to use the SPI pins in order to upload the bootloader into the device.

Can you please upload the bootloader hex file?

Any suggestions in this regard will be of great help.
"Imagination is more important than knowledge."<br />-Einstein

MarekBujko


alexkurtzmanisahack

So i've received a usb drive as a present that looks exactly like the one in Nico's post except it isn't labeled.
Since it seemed a bit suspicious i've decided to check it out in a VM. After about 5s it starts a cmd prompt and that's about it.

So..i don't have any Arduino or BadUSB experience but i'd like to turn this device into something useful like a security key necessary for the windows login.

So far i've disassembled the drive, downloaded and installed the Arduino IDE.

Is it possible to connect the pcb directly via USB to my laptop? I'd know where to connect the red and black wires but what about the white and green one?

Nico_TheDecoder

Thanks for the feedback  :smiley-twist:
It's great to see someone can use this for something :)


I've updated #0 a little bit.

Now also with link to Original Leonardo Bootloader HEX & all pinouts (also USB) via Google Drive.


Unfortunately, I am rarely online on this forum, so do not expect me to respond very quickly  :smiley-sad:  :smiley-cry:

Go Up