Changing display resolution on Rasbian

Settings such as HDMI video output are configured in the /boot/config.txt file – you can edit this on the Pi with ‘sudo nano /boot/config.txt’. If you need to edit on another machine, see details here.

This page lists available video modes. On my LG E2341 connected by HDMI, uncommenting and changing these two settings works to set the output to 1080p:

hdmi_group=1

hdmi_mode=16

 

 

Mounting Linux ext partitions on OS X

I wanted to check some files on an SD Card formatted in ext that I had used on my Pi and wanted to check if I had left some files in the home dir before I reimaged it. OS X doesn’t support ext formatted drives by default, but you add support using OSXFuse.

  • Install Fuse for OS X
  • Install the ext plugin for Fuse
  • Find the partition you want to mount with: diskutil list
  • Make a mount point – not sure on Mac OS X where is the best place, but I added /mnt/sdcard
  • Mount with:


    [code]sudo fuse-ext2 /dev/disk1s2 /mnt/sdcard[/code]

  • (replace with the /dev/ to your device)

I’m not sure if it’s best practice on the Mac to mount with sudo, but this worked for me for what I needed to do. Fuse mounts on ext are r/o by default, but there is experimental r/w support that can be enabled, check the docs.

Done!

Calling C printf from ARM ASM

A while back I started to learn some ARM assembly on the Raspberry Pi. In my previous snippets, I was using SWI to do a system call to write to stdout, but it appears syscall 4 to write to stdout only writes Strings – if you have a byte value, this approach doesn’t work (without converting to a String first?)

From this question here, it appears you can call C functions like printf, which seems like cheating a bit, but I guess it gets the job done.

Here’s a quick snippet to add two numbers, and then print the result using printf with a string containing %d to substitute the result into the String:

[code]
.global main
.extern printf
main:
push {ip, lr}
mov r3, #1 /* move 1 to r3 */
mov r4, #2 /* move 2 to r4 */
add r4, r3, r4 /* r4 = r3 + r4 */
_ouput:
ldr r0,=output /* load address of output string */
mov r1, r4 /* move r4 result to r1 to include as param in string */
bl printf /* call printf */
_exit:
MOV R1, #0
MOV R7, #1
SWI 0
.data
output:
.asciz "Result: %d\n"
[/code]

Where previously I was compiling and linking in two steps with as and ld, it seems this doesn’t work if you are referencing C functions too, so for this example, compile with: ‘gcc add.s -o add’

This snippet and a few others I’ve started to collect I’ve shared in a github repo here: https://github.com/kevinhooke/learning-arm-asm

Writing Raspberry Pi disk images to SD cards on the Mac

Just as the dd command can be used to create a disk image of an SD card on the Mac (see here), you can use dd to write a downloaded (or backup) disk image to an SD card too:

sudo dd of=/dev/rdiskx if=/path/to/image bs=1m

where x is the disk number as shown by diskutils list.