Close
0%
0%

The 1kB Challenge

The only limit is what you can do with 1 kB of program memory

Monday, November 21, 2016 08:00 am PT - Thursday, January 5, 2017 09:00 pm PT Local time zone:
Similar projects worth following

Microprocessors didn't always have Gigabytes of memory, and Microcontrollers didn't always have hundreds of kB of flash. The Hackaday 1kB challenge is a contest where entrants must create a device which uses 1kB or less of executable program code. The contest is open to any microcontroller or microprocessor architecture. Anything from Arduino board with AtMega328's to ARM and beyond. External hardware such as leds, switches, and 74 series logic chips are allowed and encouraged - but the machine code must be less than 1kB.

Official Rules:

  • Contest entry deadline is Thursday, January 5, 2017 09:00 pm PST (+8 UTC)
  • This contest is open to any microcontroller or microprocessor architecture.
  • Projects must use 1 kB or less of code, including any initialized data tables, bootloaders, and executable code.
  • <UPDATE> Unavoidable Hardcoded bootloaders such as propeller, ESP8266, or i.mx series don't count toward the 1 kB limit. Entrants can use the bootloader code to start their processor up and get their own code executing. Once things are running though, any calls into bootloader or ROM tables count against you.
  • Entrants must show how they came to the 1 kB calculation (map files, assembler/linker output, etc)
  • Existing computer systems can be used (Example - Atari 2600) however, the size of any rom routines or data tables must be included in the 1 kB calculation.
  • Mask Rom: If you are using a chip with masked rom code, you must include the size of any ROM routines you call in your final executable size calculation. If you wanted to write a program in SPIN for the Parallax Propeller, you’d need to include the SPIN interpreter ROM, which would put you over the 1 kB limit.
  • Projects can use multiple processors as long as they are running the same 1 kB binary, or if the total size of the ROM being run is less than 1 kB. (Example - two micros running different binaries which are 512 bytes long each)
  • Projects must fill out the description, details, components, and project logs.
  • Projects must be open source. Source code, schematics, and board layouts for the project software must be either posted in the files section, or include a link to a public repository such as Github.
  • Projects must use publicly accessible toolchains. Closed source toolchains (example - IAR or Keil) can be used as long as the demo versions will compile/assemble the contest code.
  • All entries will be judged by Hackaday staff.
  • Winners will be announced on or around Monday, January 16th
  • Hackaday Staff, Employees of SupplyFrame, Judges or the family of any of the preceding are not eligible to take part in this contest. Everyone is still encouraged to build awesome stuff and show it off though.

Judging Criteria:

  • Does the entry fit within the 1 kB size constraint?
  • How novel or interesting is the entry?
  • Does the documentation explain the project?
  • Are any novel techniques (example: Self modifying code) explained?
  • How complete is the entry? Projects don’t have to be complete or working to enter, however those which are finished and working by the deadline may be judged higher.

Prizes:

Any Hackaday contest needs some awesome prizes, and this one is no different.

digicomp

mselect

bulbdial

  • Grand prize is a Digi-Comp II kit from EMSL
  • First prize is a Maker Select 3D printer V2
  • Second Prize is a Bulbdial Clock kit from EMSL
  • Third Prize is a Blinkytile kit from Blinkinlabs

  • And the winners are...

    Adam Fabio01/17/2017 at 06:34 4 comments

    The 1 kB Challenge deadline has come and gone. The judges have done their work, and we’re ready to announce the winners. Before you jump down to find out who won, I’d like to take a moment to say thanks to everyone who participated. We had some incredible entries. To say that judging was hard is quite an understatement. Even [Eben Upton], father of the Raspberry Pi got in on the action. He created a new helicopter game for the classic BBC Micro. Look for writeups on the winners and many of the other entries in the coming weeks.

    Grand Prize

    brainfckThe grand prize goes to [Jaromir Sukuba] for Brainf*cktor. [Jaromir] went above and beyond this time. He created a computer which can be programmed in everyone’s favorite esoteric programming language. Brainf*cktor uses 1019 bytes of program memory in [Jaromir’s] PIC18F26K22. You can write, execute and edit programs. [Jaromir] ran into a bit of a problem with his LCD. The character tables would have thrown him over the 1 kB limit. Not a problem – he designed his own compressed character set, which is included in the 1019 bytes mentioned above. All the clever software takes physical form with a homemade PCB, and a case built from blank PCB material. Best of all, [Jaromir] has explained his software tricks, as well as included a full build log for anyone who wants to replicate his project. All that hard work will be rewarded with a Digi-Comp II kit from EMSL.

    First Prize

    mosFirst prize goes to [Dumitru Stama] with M0S – CortexM0 RTOS in 1024 bytes. Operating systems are complex beasts. Many of our readers have toyed with the Linux Kernel. But writing a real-time OS from scratch? That’s quite an undertaking. [Dumitru] didn’t shy away from the challenge. He designed a Real-Time Operating System (RTOS) for ARM processors, written completely in ARM thumb assembly instructions. This is no bare-bones executive. M0S has a rich list of features, including preemptive task scheduling, mutexes, and inter-process communication. [Dumitru] even gave us memory allocation with an implementation of malloc() and free(). The OS was demonstrated with a NUCLEO-F072RB board from ST-Micro.

    [Dumitru] didn’t just drop a GitHub link and run. He documented M0S with seven project logs and a 37-minute long video. The video uses electronic whiteboard drawings to clearly explain all the internal workings of the operating system, as well as how to use it.

    [Dumitru] is the proud new owner of a Maker Select 3D printer V2!

    Second Prize

    1klaserSecond prize goes to [Cyrille Gindreau] with 1K Challange Laser. Vector lasers generally take lots of memory. You have to manage galvanometers, laser drive, and perform all the magic it takes to convert a set of vectors to lines drawn in space. The project uses 912 bytes of program and initialized data memory to command an MSP430 to draw an image.

    Proving that flattery will get you everywhere, [Cyrille] picked the Hackaday logo as the subject. The Jolly Wrencher is not exactly simple to convert to vector format, though. It took some careful optimizations to come up with an image that fit within 1 kB. [Cyrille] wins a Bulbdial Clock kit from EMSL.

    Third Prize

    tinygamesThird prize goes to [Mark Sherman] with tinygames. Video games have been around for awhile, but they are never quite this small. [Mark] coaxed the minuscule Atmel ATtiny84 to play Centipede with only 1024 bytes of program memory. Even the BOM is kept small, with just a few support components. Control is handled by an Atari 2600 compatible joystick. Video is black and white NTSC, which is demonstrated on a period accurate CRT. [Mark] generates his video by racing the electron beam, exactly the same way the Atari 2600 did it.

    [Mark] will take home a Blinkytile kit from Blinkinlabs.

    Final thoughts

    First of all, I’d like to thank the judges. Our own [Jenny List], [Gerrit Coetzee], [Pedro Umbelino], [Bil Herd], and [Brian Benchoff] worked hard with me in judging this contest. I’d also like to thank our community for creating some amazing projects. The contest may...

    Read more »

  • Judicial Deliberations

    Adam Fabio01/07/2017 at 08:06 3 comments

    The 1 kB challenge deadline has passed. With 133 entries, this contest has exceeded our wildest expectations! Thank you to everyone who entered. The judges are now hard at work reviewing each entry.

    Keep an eye on this space (or in your feed if you follow the contest) for an announcement of the winners!

    Thanks again to everyone!

  • CPLDs, FPGAs, and hard bootloaders

    Adam Fabio11/23/2016 at 03:15 0 comments

    It's come to my attention that the rules excluded a few architectures which have bootloaders hard coded to run at powerup. An example of this is the parallax propeller, which must run the spin interpreter before firing off a PASM routine. The spirit of the rules is leveling the playing field - not excluding any particular processor. As such I've updated the rules to allow hard coded bootloaders. Check it out!

    Quite a few people have been asking about CPLDs and FPGAs. First off, custom processors instantiated in FPGA's are allowed, and encouraged! CPLD/FPGA external logic is also perfectly fine to use, but remember this is a contest about fitting a lot of function into a little codespace. A ton of perfectly executed Verilog or VHDL code to implement a state machine won't impress the judges as much as a well crafted 1 kB routine. The same goes for Analog or even mechanical entries. Don't worry - there are more contests coming down the pipe for your analog and mechanical hacks!

  • Details coming soon...

    Adam Fabio11/14/2016 at 01:59 0 comments

    Stay tuned for the official rules and details!

View all 4 contest logs

Enjoy this contest?

Share

Discussions

Clovis Fritzen wrote 11/16/2016 at 04:15 point

Very dumb questions: 1- is 1kb the number I'm looking at for the compiled file? 2- In  case of a bootloader, will it count inside the 1kb?

  Are you sure? yes | no

K.C. Lee wrote 11/16/2016 at 04:27 point

I would assume that your compiler would have a message saying how much actual storage space is used for the program instead of the programming file created.  That file may have some other debugging stuff in it or in a format for the programmer instead of actual image, so the file size is not accurate.

In my case, it looks something like this for ARM for the compiler messages.  

linking...
Program Size: Code=112 RO-data=32 RW-data=0 ZI-data=256

Code: that's obvious
RO-data: tables, data structure stored in ROM. 

It is my previous question whether that is counted in the 1kB limit.  Straightly speaking that is not machine code.  Need a clarification on the rules as my question was derailed by another comment.

ARM got huge vector table (200+ bytes) in RO-data, so it is a big disadvantage if I want to use interrupts.

RW-data = RAM 
ZI-data = preinitialized to zero RAM data

If it is not in the messages, then there is a .map file with a report usually as a summary.  I don't do Arduinos, so can't answer specific question to that.

Code (inc. data)   RO Data    RW Data    ZI Data      Debug   

       112         24         32          0        256       2828   Grand Totals
       112         24         32          0        256       2828   ELF Image Totals
       112         24         32          0          0          0   ROM Totals

    Total RO  Size (Code + RO Data)                  144 (   0.14kB)

    Total RW  Size (RW Data + ZI Data)               256 (   0.25kB)
    Total ROM Size (Code + RO Data + RW Data)        144 (   0.14kB)

  Are you sure? yes | no

Eric Hertz wrote 11/16/2016 at 10:36 point

PIC32 might be even worse... you should see the listing from "xc32-size" for my projects, there's something like 60 different  sections. I have no idea how to add them up to determine actual bytes-written to the FLASH. I think some are configuration-registers-stored-in-flash. Others are jump-tables for interrupts, but all those are written to jump to a general exception-handler, even if the interrupts aren't configured. 

-----------

I don't think either of these questions are dumb. There'd have to be a lot of gray-area rules-wise in this contest, not being limited to a specific microcontroller/architecture. If someone comes up with the next amazing/unique USB-gadget but uses the USB-functionality built into their uC's peripherals and libraries supplied by the manufacturer, should that be rated more highly than a USB-blinky which figured out a clever way to "hook" into a previously-untapped commonplace-bootloader whose USB-support was bit-banged? 

If anything, these aren't "dumb" questions, but fundamental questions regarding life, liberty, and all that jazz.

Or, more specifically, as a fellow "hacker", I'd say:

1) Definitely don't rely on the file-size. Use "avr-size" or "xc32-size" or "arm-size"(?) to get a table more like KCLee's, if your compiler doesn't give you that information already. And don't be surprised if it's not at all intuitive (seriously, my AVR project easily fits in my 8KB of flash, but allegedly there's some ".debug" section well over 32KB? How does *that* work?!)

2) Bootloaders... There seems to be a strange, yet understandable, silence on this front. Whelp, there are those who use Arduinos and don't even know there's such thing as a bootloader, despite using them in every project, and there are others who would try something like suggested earlier... There might even be those who would use a bootloader such as grub to gain full 1080p frame-buffer support on an x86-64, then write a 1KB "demo" which wows the crowd.

All I, fellow-hacker, can say about that is... unless the judges explicitly banish them from this contest, which would put a tremendous burden on newbies' creativity--which would kinda ruin the point of contests like these, no?--nevermind a slew of other such pedantry which has yet to come up, the judges are going to have a *lot* of work ahead of them, and after the fact likely quite a bit of judgment. We should be giving these folks unquestionable "props" (that is: "Proper Respect") for their part in these things.

  Are you sure? yes | no

vlk wrote 11/17/2016 at 10:01 point

ARM: if you don't use any interrupts, then you can reuse vector table space for your code. And if you are sure that HARDFAULT handler never happened then you need to use only stack pointer and RESET handler, this eat only 8 bytes of code.

  Are you sure? yes | no

K.C. Lee wrote 11/17/2016 at 10:43 point

Hardfault handler would be a final option as I can waste a lot of time chasing ghosts.  I have 3-4 different uC architectures that I could use and still undecided on the actual projects.

  Are you sure? yes | no

DTeel wrote 11/16/2016 at 02:02 point

1. program an atmega328 to have one input, and one output

2. output=not(input)

3. make it be 1kb

4. profit?

  Are you sure? yes | no

gianlucag wrote 11/25/2016 at 00:09 point

dude, must be something memorable, not just a NOR gate on steroids :-)

  Are you sure? yes | no

jareklupinski wrote 11/15/2016 at 20:34 point

finally a reason to get my attiny10 out of the parts bin! if only i could find it...

  Are you sure? yes | no

K.C. Lee wrote 11/15/2016 at 18:56 point

>machine code must be less than 1kB.

Does that means that RO data usage (ie ROM tables for data) are not counted?

  Are you sure? yes | no

Eric Hertz wrote 11/15/2016 at 20:54 point

LOL, loving all the ideas people are coming up with to get around the size-limit... So, then, say you've got an SD-card, and all it takes is 1KB to bootload from that? I mean, that's a major gray-area, but... what if it's an interpretted-language, rather than code that runs *directly* on the machine-architecture? ROM-tables... that's great! Personally, I think it should only be allowable in the case that you've implemented the ROM tables *outside* the processor's dedicated flash/program-memory. Throw an EEPROM at it :)

  Are you sure? yes | no

Eric Hertz wrote 11/16/2016 at 08:22 point

Apologies! I didn't realize my earlier comment was a derailment of your question... I was applauding what I thought was your creative/out-of-the-box-solution, as I thought you were trying to hack e.g. a typically-large program into a small amount of code-space via e.g. creating huge lookup tables, *and* trying to get away without having to count those lookup tables toward the 1KB.

(E.G. Why make your lowly uC calculate something like (int)( 128 + 128*sin(theta) ) in realtime when a suitable LUT is much faster and might be smaller than loading support for floating-point?)

I can see how it'd be confusing as to whether your project would qualify if you're using a uC with more program-space than the contest's requirement. I recall my first experience filling up my AVR's program-space... didn't make sense, the code (.text) section was well-under the 8KB flash-size, but I didn't know that additional flash/program-memory is necessary for initializing global variables... (is that the .bss or .data section?).

So, you bring up a good side-question... now that you've declared this thread "derailed".... (and since you've discussed the topic in another thread, above).

Should those who *unknowingly* stumble upon this be penalized for it in the context of this contest? Doesn't seem particularly fair, in terms of disqualifying otherwise interesting projects that did their best to work within the rules.

OTOH, those who *know* about it could easily come up with a way to make use of techniques like these to stretch the contest's rules... That might be considered unfair, or it might be considered a clever use of one's understanding, aka "a hack," which otherwise might be respectable in a place like Hackaday.

OTOOH, now that this knowledge *has* been put on the table...?

Gotta give props to the judges of these contests for working through these sorts of dilemmas in a place with such a broad array of experience/perspective.

Hope you got the answer you were looking for.

  Are you sure? yes | no

Adam Fabio wrote 11/16/2016 at 06:19 point

(This is preliminary and the rules may change)  RO Data must be included in the 1kB calculation.  It puts ARM at a disadvantage - if you use interrupts. 

  Are you sure? yes | no

K.C. Lee wrote 11/17/2016 at 00:40 point

Thanks.  I know a couple of ways around that.

In general, ARM is at a disadvantage for tiny space as I/O registers are memory mapped in 32-bit space unlike the 8-bit I/O space which carries a bit of overhead.  The peripherals also require a few more things to be initialized.  :(

Once you get to higher level codes, the code density is actually pretty good and get better when you start having to do with larger data size.

  Are you sure? yes | no

Patrick Van Oosterwijck wrote 11/15/2016 at 18:12 point

Aw man! Early #LiFePO4wered/Pi prototypes used to have < 1K, but production now uses 2K. :)

  Are you sure? yes | no

Ted Yapo wrote 11/15/2016 at 15:36 point

Also, the 1kB limit is the size of the initial assembled instructions themselves, right?  If I have an initial 1kB of instructions that grows to fill a larger piece of executable space, that's still OK, right?  Oh, I've said too much already...

  Are you sure? yes | no

Ben Hencke wrote 11/15/2016 at 16:47 point

indeed! this is going to be too fun!

  Are you sure? yes | no

Eric Hertz wrote 11/15/2016 at 20:57 point

Or have you said enough?

  Are you sure? yes | no

Ted Yapo wrote 11/15/2016 at 22:13 point

I have found that I generally always say too much :-)

  Are you sure? yes | no

Adam Fabio wrote 11/16/2016 at 06:15 point

(This is preliminary, and the rules may change) If you want to compress your code, go for it - but remember, the decompression algorithm and the compressed binary must both fit within 1kB.  

  Are you sure? yes | no

Eric Hertz wrote 11/16/2016 at 08:36 point

Hahaha, I had no idea you were talking about compression until Adam's response... brilliant!

  Are you sure? yes | no

Ted Yapo wrote 11/16/2016 at 17:52 point

I am going to blame Linus for all the time I'll end up sinking into trying to make a compressed PIC image.  After I saw this contest announcement, I upgraded my linux desktop distro, and noticed it say "uncompressing linux" as it booted.

  Are you sure? yes | no

Ben Hencke wrote 11/15/2016 at 15:09 point

Are multiple microcontrollers allowed, and if so are duplicates allowed? e.g. 2 microcontrollers running identical 1kB code.

  Are you sure? yes | no

Hacker404 wrote 11/15/2016 at 07:33 point

Sounds great but I have too much happening to do this sort of thing at short notice so I hope it's an ongoing thing. 

And ... C2 00 D0 // is machine code

but ... JP D000h // is assembly

No one does machine code anymore - well since assemblers were written.

  Are you sure? yes | no

zakqwy wrote 11/14/2016 at 20:46 point

Does the memory limit include a bootloader (i.e. Arduino)? If so, folks using anything but a bare micro might have some trouble..

  Are you sure? yes | no

davedarko wrote 11/15/2016 at 03:04 point

there are attiny13 avrs that only fit 1kb and can be programmed with an arduino over the IDE - that way you (or folks) would be safe :)

  Are you sure? yes | no

davedarko wrote 11/14/2016 at 16:58 point

Maybe the link in the sidebar can be fixed now? :) 

  Are you sure? yes | no

K.C. Lee wrote 11/14/2016 at 22:14 point

It couldn't fit in 1kB.  :)

  Are you sure? yes | no

Sophi Kravitz wrote 11/15/2016 at 02:08 point

that's right

  Are you sure? yes | no

Eager to get building?

Become a member and discover thousands of projects