Place onion, butter and brown sugar into a large frying pan over low heat. Cook, stirring occasionally, until the onions have caramelised, about 45 minutes.
Preheat the oven to 180 C / Gas 4. Lightly grease a 20x30cm baking dish with butter.
Place a single layer of potato slices in the bottom of the prepared baking dish. Cover with a thin layer of onions. Drizzle some of the cream, and sprinkle some of the rosemary over the layer. Repeat layers four times ending with onions, cream and rosemary.
Bake for 1 hour in the preheated oven, or until top potatoes are golden brown and sauce is bubbling.