Oberon RTK

gen-bin-res

Create binary resource files for embedding binary data in Astrobe Oberon programs

Name

gen-bin-res – create a binary resource file from a binary file

Synopsis

gen-bin-res <bin_file> [-o <rsrc_file>]

Description

gen-bin-res converts any binary file into an Astrobe binary resource file. The resource file can be linked into an Oberon program and read at run-time using the BinRes library module.

The tool prepends a 4-byte little-endian size header containing the original data length, copies the binary data, and pads the result with zero bytes to the next 4-byte boundary.

Resource File Format

The output file has the following layout:

offset  content
0       data length (4 bytes, little-endian)
4       binary data (original file contents)
4+len   zero padding (0--3 bytes, to 4-byte alignment)

The 4-byte alignment ensures that the linker places the resource data at a word-aligned address in the program image.

Using Binary Resources

To embed a binary resource in an Astrobe program:

  1. run gen-bin-res to create the .res file
  2. create a companion Oberon module with the same filename stem (for example, IceData.res requires IceData.mod)
  3. import the companion module in the program
  4. the Astrobe linker embeds the resource data in the program binary
  5. at run-time, use the BinRes module to access the data

The companion module can be empty – its purpose is to give the linker a module to associate with the resource data. The BinRes library module provides procedures to read the embedded data at run-time.

A typical use case is embedding FPGA bitstream files for configuration via SPI at startup.

Supported platforms: Windows and macOS.

Arguments

bin_file
binary file to convert (positional, required).

Options

-o rsrc_file
output resource file name. Default: bres.res.

Output

The resource file is written to the current directory (or to the path specified with -o). The default name is bres.res.

Examples

Create a resource file with the default name:

gen-bin-res rgb_blink.bin

Create a resource file with a specific name:

gen-bin-res rgb_blink.bin -o IceData.res

Diagnostics

  • "cannot find binary file" – the specified input file does not exist
  • "cannot create resource file" – the output file cannot be opened for writing

Last updated: 7 March 2026