How to access scratch register 99?

It’s mentioned in Jetson TX2 Update and Redundancy document that MB1 leaves information for slot A or slot B boot in that register for later MB2, CBoot or later stage loader to use.

How to access it? prefer in C code.


Tried to access the scratch 99 register in u-boot using ‘md’ command and it’s all 0.
The offset I got is (NV_ADDRESS_MAP_SCRATCH_BASE + SCRATCH_SCRATCH_99) == 0xC390ADC in u-boot memory space.
Am I missing something?

hello jack.hsia,

could you please share some backgrounds, may I know what’s your usage of accessing this scratch register?
you may refer to the documentation, Jetson AGX Xavier/TX2 Update and Redundancy to enable A/B redundancy.

The plan is to let uboot know which slot (A/B) booted from and track retry_count to take appropriate action.

Better still, if uboot can alter retry_count so that next reset will switch to slot.

Hi @JerryChang,

I’ve ported this code into uboot and it ‘tegrabl_get_boot_slot_reg()’ returns 0.
What do you think is the issue?

Can I get hold of ‘nvbootctrl’ and ‘nv_update_engine’ source code?

#ifndef _MK_ADDR_CONST
#define _MK_ADDR_CONST(_constant_) _constant_
#define NV_ADDRESS_MAP_SCRATCH_BASE				205062144
#define SCRATCH_SCRATCH_99                      _MK_ADDR_CONST(0xadc)

#define NV_READ32(a)        *((const volatile uint32_t *)(uintptr_t)(a))

uint32_t tegrabl_get_boot_slot_reg(void)

hello jack.hsia,

the function call to access SCRATCH_SCRATCH_99 address for the boot-slots looks correct. but it’s MB1 to select the boot slot, which is part of bpmp firmware. u-boot being the last bootloader process to load kernel images. please also check Jetson TX2 Boot Flow for reference.

you should also refer to Flashing U-Boot Only, please note that u-boot is flashed to the kernel partition and it’s also have A/B redundancy.
for example,

[  86.0954 ] Writing partition kernel with boot_sigheader.img.encrypt
[  86.1045 ] [................................................] 100%
[  86.1261 ] Writing partition kernel_b with boot_sigheader.img.encrypt
[  86.1373 ] [................................................] 100%

you may check Manually Modifying Boot Slots to enable get-current-slot option from the kernel side.

there’s no plan to release the source code of “nvbootctrl” and also “nv_update_engine”.

@JerryChang how do we get/deduce NV_ADDRESS_MAP_SCRATCH_BASE and SCRATCH_SCRATCH_99?

Is it the same for TX2 and Xavier? I need both.

Hi @lfdm , did you manage to read/change the register value from u-boot or from the kernel? If yes, could you share the snippet please? Thank you

@AlexCo something messed up with NVidia accounts, I cannot recover my old one…

I didn’t. I started using the C-Boot only bootloader configuration you can find in the meta-tegra layer for yocto. With u-boot removed, I get the slot suffix from kernel arguments and handle the rootfs partition selection in initramfs.

1 Like